Skip to page content or skip to Accesskey List.
Search evolt.org
evolt.org login: or register

Work

Main Page Content

Let the User Skip the Splash Page

Rated 3.92 (Ratings: 2) (Add your rating)

Log in to add a comment
(6 comments so far)

Want more?

 
Picture of aardvark

Adrian Roselli

Member info | Full bio

User since: December 13, 1998

Last login: October 28, 2009

Articles written: 62

The proliferation of splash pages on web sites has been seen by many to be a hindrance to the user. A splash page generally consists of a default home page that displays the company logo, or some other branding for the site and/or company, using everything from Flash movies to animated graphics.

What most site designers forget is that while their desire to brand their site may be important, it slows down the user every time that user has to wait for it to download, and then click through (provided that option has been offered by the designer). So instead of forcing the user to circumnavigate the page with bookmarks or directly typing the page address in to his or her browser, we assume that once is enough. Or, in the case of this tutorial, once a month is enough.

I am offering two solutions within this article. One is for those of you who do not have access to server-side scripting and is written in JavaScript. The other is writtin in VBScript for Active Server Pages, but the concept is simple enough and may be easily repurposed for other server-side scripting languages.

What We're Doing

We will set a cookie on the user's computer indicating that the user has seen the splash page already. The next time the user comes back, the script will look for the cookie. If the cookie is there, the splash page is skipped, if the cookie is not there, the splash page is displayed. The cookie expires after a pre-determined amount of time.

JavaScript Solution

You should paste the following code block in the <HEAD> of your HTML page. There are comments strewn about within it, so make sure you don't paste those in.

<script language="JavaScript">
<!--

function ReDirect (URL) {

GetCookie('SplashSkip');

if (Splash == 'TRUE') {
  window.location=(URL);
}
else {}
}

var Splash = GetCookie('SplashSkip');

The above block of script creates the redirect function that will kick the user out of the splash page when called. The first thing the function does is look for a cookie called SplashSkip. If that cookie has a value of TRUE then it changes the URL of the current page to whatever the value for URL is as defined below.

Setting Splash equal to the GetCookie function with the SplashSkip variable allows us to look for the cookie named SplashSkip without having to hardcode the value into the GetCookie function.

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (';', offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
  var arg = name + '=';
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
  var j = i + alen;
  if (document.cookie.substring(i, j) == arg)
    return getCookieVal (j);
  i = document.cookie.indexOf(' ', i) + 1;
  if (i == 0) break;
  }
  return null;
}

The two functions above actually retrieve the values of any cookies passed to them, while making sure the script doesn't fall apart on older browsers, or on a browser with no cookie(s) set.

ReDirect('http://foo.com/skipsplash.html');

This piece of script above is the only function that is run as soon as the page begins to load. The ReDirect function as defined above now kicks in, which checks for the specified cookie. If that cookie doesn't exist then the function ends, as you can see in the else {} statement above. The target URL is placed in the parentheses.

function SetCookie (name, value) {
  // Enter number of days the cookie should persist
  var expDays = 30;
  var exp = new Date();
  exp.setTime(exp.getTime() + (expDays * 24 * 60 * 60 * 1000));
  expirationDate = exp.toGMTString();
  // Set cookie with name and value provided
  // in function call and date from above
  document.cookie = name + '=' + escape(value)
  document.cookie += '; expires=' + exp.toGMTString();
}

// -->
</script>

This final snippet of code creates the function that sets the cookie. This function is called after the page has loaded, and so only runs if the user wasn't moved to a new page by the redirection function that loaded as soon as the page opened. You set the number of days the cookie lasts on the user's machine by changing the value of expDays.

&lt;body>

Finally, you add the JavaScript þcodeÿSetCookie
function to an onLoad event in your &lt;body&gt; tag. The example above defines the cookie name and value, which is what the rest of the script checks against in order to skip the splash page.

ASP/VBScript Solution

This script still sets a cookie, but all the work is done by the server. Instead of the splash page flashing on screen for a moment, as it does with the JavaScript solution, this script just serves up a completely different page. The first thing you need to do, before the &lt;head&gt; tag, or anything else in the ASP file, is paste the following code:

<%
IF Request.Cookies("ASPSplashSkip") = "TRUE" THEN
  response.redirect "http://foo.com/skipsplash.html"
ELSE
  SET_COOKIE
  HTML
END IF
%>

The first thing the script does is look for a cookie with the name ASPSplashSkip and value of TRUE. If that cookie exists, you are immediately served up a different page, and the splash page has been skipped.

If the cookie is not there, it goes on to the next part, which consists of displaying two SUBs, which are just pieces of HTML and/or script wrapped in &lt;% SUB %&gt; containers. In this case, the function that sets cookies is wrapped in one, and the actual HTML of the page is wrapped in another. I tend to use SUBs since it helps me to quickly and easily modify what happens in my ASP scripts when I have pieces of logic driving what gets displayed -- as I do here.

<% SUB SET_COOKIE %>
<%
'###############
'## Date Setting

DayLater = DateAdd("d", 1, FormatDateTime(Now,vbGeneralDate))
WeekLater = DateAdd("ww", 1, FormatDateTime(Now,vbGeneralDate))
MonthLater = DateAdd("m", 1, FormatDateTime(Now,vbGeneralDate))

  '## Choose a timeframe from above and
  '## make it equal to TargetDate
  TargetDate = MonthLater

'##################
'## Cookie Setting

  '## This sets the cookie so that the next time the
  '## user comes back he/she will skip the splash page
  Response.Cookies("ASPSplashSkip") = "TRUE"
  Response.Cookies("ASPSplashSkip").expires = TargetDate

%>
<% END SUB %>

The first part allows you to select a timeframe for the expiration of the cookie. I have provided three timeframes to make it easy, since you can't just enter a number of days as you can with the JavaScript. So if you decide you only want the cookie to last one week before expiring, set TargetDate equal to WeekLater.

The second part sets the cookie with the name/value pair you see in quotes. In this example, the name is ASPSplashSkip and the value is TRUE. It also sets the expiration date for the cookie based on the value you set for TargetDate.

<% SUB HTML %>
<HTML>

<!-- Insert splash page here -->

</HTML>
<% END SUB %>

Finally, whatever is within the &lt;% SUB HTML %&gt; and &lt;% END SUB %&gt; containers is the actual content of your splash page. The example above is trimmed to just the &lt;HTML&gt; tags, but you can have any HTML in there, including your Flash splash movie, or your DHTML effects, or whatever else goes on that splash page.

Samples

See an example of these scripts work with an ASP page, or see it work with a plain HTML page using JavaScript.

Finally

Remember that this doesn't guarantee a user won't see a splash page more than once a month (for this example), especially if they switch browsers or have cookies turned off, but it's a good start. This also doesn't mean you shouldn't re-examine the utility of your splash pages. They should still be functional, and should still offer a way to get to the real content of your site for the user who actually sees it.

A founder of evolt.org, Adrian Roselli (aardvark) is the Senior Usability Engineer at Algonquin Studios, located in Buffalo, New York.

Adrian has years of experience in graphic design, web design and multimedia design, as well as extensive experience in internet commerce and interface design and usability. He has been developing for the World Wide Web since its inception, and working the design field since 1993. Adrian is a founding member, board member, and writer to evolt.org. In addition, Adrian sits on the Digital Media Advisory Committee for a local SUNY college and a local private college, as well as the board for a local charter school.

You can see his brand-spanking-new blog at http://adrianroselli.blogspot.com/ as well as his new web site to promote his writing and speaking at AdrianRoselli.com

Adrian authored the usability case study for evolt.org in Usability: The Site Speaks for Itself, published by glasshaus. He has written three chapters for the book Professional Web Graphics for Non Designers, also published by glasshaus. Adrian also managed to get a couple chapters written (and published) for The Web Professional's Handbook before glasshaus went under. They were really quite good. You should have bought more of the books.

Submitted by Anonymous on October 20, 1999 - 15:27.

If I'm correct this would be a Perl version ( don't quote me on this as I'm just making this up as I get along ) : P.S. Cookies.pm is just your basic cookie lib. use Cookies ; $skip = &GetCookie( 'skip' ) ; if ( $skip eq 'yes' ) { print "Content-type: text/html\nLocation: http://www.mysite.com/page2.html\n\n" ; } else { print "Content-type: text/html\n" ; &SetCookie( "skip" , "yes" , "+1M" ) ; print "\n" ; open FILE , "splash.txt" ; while ( ) { print ; } close FILE ; }

login or register to post comments

Escaping site

Submitted by colesmj on June 14, 2001 - 12:47.

Unfortunatly the redirect of the JS version does not allow the user to get back off the site using the back button ... handy in some cases perhaps but not most mar

login or register to post comments

Better JavaScript?

Submitted by aardvark on June 14, 2001 - 12:58.

You are absolutely correct that the JS redirect doesn't allow the user to back up to the previous site. Do you have a better way to handle the redirect in JS? I am completely open to suggestions.

login or register to post comments

Solution hopefully...

Submitted by colesmj on June 18, 2001 - 13:02.

Ok here goes for a solution .... code first ...

var Splash = GetCookie('SplashSkip');
var ReDirected = GetCookie('SplashReDirected');

ReDirect('_YOUR_URL_');

function ReDirect (URL) {

	SetCookie('SplashSkip','TRUE',1);

	if (Splash == 'TRUE' && ReDirected != 'TRUE' ) {
		SetCookie('SplashReDirected','TRUE');
		window.location=(URL);
	}
}

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
  var j = i + alen;
  if (document.cookie.substring(i, j) == arg)
    return getCookieVal (j);
  i = document.cookie.indexOf(" ", i) + 1;
  if (i == 0) break; 
  }
  return null;
}

function SetCookie(name, value, expDays, path, domain, secure) {
	// Set cookie with name, value etc provided
	// in function call and date from above
	// Number of days the cookie should persist NB expDays='' or undef. => non-persistent
	if (expDays != null ) {
		var expires = new Date(); 
		expires.setTime(expires.getTime() + (expDays*24*60*60*1000));
	}	
	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}


...basically it now uses a per-session cookie as well that only allows one redirect per session so the browser can go back if they want to.
Also changed the SetCookie() function as in my MSIE5.5 the original cookie only seemed to be being set as a per-session ... as always could be just 'me' ...but now its more generic for adapting to other purposes ...
hope this helps
mar

login or register to post comments

Another variation??

Submitted by dstewart21 on September 16, 2001 - 22:56.

Would it be difficult to tweak this in such a way that would ALSO allow the end user to skip always? Much like the script on http://www.screamdesign.com Thanks in advance. Stew

login or register to post comments

Using SharedObjects to skip the intro in your SWF

Submitted by lostpear on November 13, 2003 - 14:25.

I see how the JavaScript works to redirect the URL and it does work fine... but what if that's not an option. Is there a way to simply work with the same HTML/URL and the SWF file jump to a label within the same movie?

I've seen SharedObjects used in games as in (your last score was "blah blah") but how can I apply that to a jump to label in my flash timeline? Is that possible? Is there a security problem that this isn't recommended anymore? Do I have to use ASP or ColdFusion to set cookies instead?

Any help out there would be greatly appreciated. Thanks.

login or register to post comments

The access keys for this page are: ALT (Control on a Mac) plus:

evolt.orgEvolt.org is an all-volunteer resource for web developers made up of a discussion list, a browser archive, and member-submitted articles. This article is the property of its author, please do not redistribute or use elsewhere without checking with the author.