...

View Full Version : Resolved Only on first visit to site



ubh
10-08-2008, 04:40 PM
Hi, been working on my portfolio page:
CLICK HERE (http://www.geocities.com/ubhiceist/index.html)

When the page first loads I am using some javascript to create a loading slash screen inorder to make sure that the pages content is compleatly loaded before I call the splash page to fadeout and the rest of the page to fade is. This way my fades are not as choppy while trying to load the page content simultaneously.

My questions is how would I go about making this loading splash screen only happen to a visitor when they first arrive, and not if they hit refresh in the browser?

abduraooft
10-08-2008, 04:53 PM
You could use cookies

ubh
10-08-2008, 05:09 PM
hmm cookies huh, darn. I don't know, I always have had a bad impression of the cookie use. I mean relying on the client side to:

A)Accept Cookies
B)Have a browsers that handles cookies
C)Hope the client has not removed my cookie

Are there any statistics that can show the ups and downs of using cookies, or maybe some of you have an opinion and/or first hand account with using cookies on your site?

Basscyst
10-09-2008, 12:15 AM
To put things into perspective, you are depending on javascript to remove the splash screen. So users with JS disabled see only a gray screen and never any content.

So I'd suggest, first defaulting to no splash screen. Then if JS is enabled, load the spash screen with javascript. Prior to though, check if cookies are enabled by setting one and trying to read it. If it is readable set the cookie that prevents the splash screen from reloading, then load it. If they don't have cookies you can either skip the splash screen all together or just have the splash screen load every time.

Most important though is the fact that in it's current state, any user with javascript disabled will never see your content.

ubh
10-09-2008, 01:39 AM
duhh I completely forgot about JS enabled haha wow.

Ok so I removed all the opacity CSS rules from my style sheet and have DOM setting the opacity rules inline to avoid the JS enabled problem.

Now I am trying to run with the cookies (still a bit nervous about using cookies but realize I have no choice), I am trying to following this tutorial begins I have never worked with cookies and expand it onto my needs but so far no go.
Cookies enabled test (http://techpatterns.com/downloads/javascript_check_cookies.php)

BTW my domain has moved to:
http://www.devinrolsen.com

Here is my code.

Set_Cookie( 'test', 'none', '', '/', '', '' );
if ( Get_Cookie( 'test' ) )
{
cookie_set = true;
Delete_Cookie('test', '/', '');

Set_Cookie( 'devinrolsen', '1', '', '/', '', '' );

if( Get_Cookie( 'devinrolsen' ))
cookie_set = true;
window.scrollBy(0,-120);
window.scrollBy(0,121);
else
{
cookie_set = false;
//SET OPACITY FOR ELEMENTS
var getHeader = document.getElementById("header");
getHeader.style.opacity="0";
getHeader.style.filter="Alpha(opacity=0)";

var getLogo = document.getElementById("logo");
getLogo.style.opacity="0";
getLogo.style.filter="Alpha(opacity=0)";

var getNav = document.getElementById("navigation");
getNav.style.opacity="0";
getNav.style.filter="Alpha(opacity=0)";

var getMain = document.getElementById("main");
getMain.style.opacity="0";
getMain.style.filter="Alpha(opacity=0)";

var getContent = document.getElementById("content");
getContent.style.opacity="0";
getContent.style.filter="Alpha(opacity=0)";

var getBgDeco = document.getElementById("bg_deco");
getBgDeco.style.opacity="0";
getBgDeco.style.filter="Alpha(opacity=0)";

var getNavArrow = document.getElementById("nav_arrow");
getBgDeco.style.opacity="0";
getBgDeco.style.filter="Alpha(opacity=0)";


window.scrollBy(0,-120);
window.scrollBy(0,121);
var docBody = document.getElementsByTagName('body')[0];
docBody.style.background="url(images/loading.gif)";
docBody.style.backgroundColor="#797979";
docBody.style.backgroundPosition="center center";
docBody.style.backgroundRepeat="no-repeat";

setTimeout('opacityLoad()',4000);
}

}
// if the Get_Cookie test fails, cookies
//are not enabled for this session.
else
{
cookie_set = false;
}
Any Ideas?

ubh
10-09-2008, 03:13 AM
Wow I got it to work.

I really recommend this cookie lib to anyone who is working with them for the first time. Javascrip Cookie Lib (http://techpatterns.com/downloads/javascript_cookies.php)

Check the site out now:
My Site (http://www.devinrolsen.com)

Only problem is that its got a tiny flicker on when the page loads and when the opacity's are set with DOM so you see the page and then the "loading splash screen" for a split second.

I dont quite know what it is thats doing it but if there is a way to make it stop that would be the best x-max present a person could ever have :)

here is my js code now.



function startLoading()
{
Set_Cookie( 'test', 'it works', '', '/', '', '' );
if ( Get_Cookie( 'test' ) )
{
Delete_Cookie('test', '/', '');

if ( Get_Cookie( 'devinrolsen' ) ){
window.scrollBy(0,-120);
window.scrollBy(0,121);
}
else
{
Set_Cookie( 'devinrolsen', 'devinrolsen', '1', '/', '', '' );
//SET OPACITY FOR ELEMENTS
var getHeader = document.getElementById("header");
getHeader.style.opacity="0";
getHeader.style.filter="Alpha(opacity=0)";

var getLogo = document.getElementById("logo");
getLogo.style.opacity="0";
getLogo.style.filter="Alpha(opacity=0)";

var getNav = document.getElementById("navigation");
getNav.style.opacity="0";
getNav.style.filter="Alpha(opacity=0)";

var getMain = document.getElementById("main");
getMain.style.opacity="0";
getMain.style.filter="Alpha(opacity=0)";

var getContent = document.getElementById("content");
getContent.style.opacity="0";
getContent.style.filter="Alpha(opacity=0)";

var getBgDeco = document.getElementById("bg_deco");
getBgDeco.style.opacity="0";
getBgDeco.style.filter="Alpha(opacity=0)";

var getNavArrow = document.getElementById("nav_arrow");
getBgDeco.style.opacity="0";
getBgDeco.style.filter="Alpha(opacity=0)";


window.scrollBy(0,-120);
window.scrollBy(0,121);
var docBody = document.getElementsByTagName('body')[0];
docBody.style.background="url(images/loading.gif)";
docBody.style.backgroundColor="#797979";
docBody.style.backgroundPosition="center center";
docBody.style.backgroundRepeat="no-repeat";

setTimeout('opacityLoad()',4000);
}
}
}

ubh
10-09-2008, 03:55 AM
What the heck is this crap? Why are you spamming in my topic? I have question up in the air and you come along with this crap?

Thanks.

abduraooft
10-09-2008, 08:02 AM
What the heck is this crap? Why are you spamming in my topic? I have question up in the air and you come along with this crap?

What happened to you?

ubh
10-09-2008, 01:21 PM
oh nothing its been removed, someone came in and was spamming an advertisement.. I was just a little perplexed at the whole thing :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum