Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Web Design & Development
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming gpu hard drive hardware hdmi internet laptop malware memory monitor motherboard netgear network printer problem ram registry router security slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Solved: Strange opening order on a page using java, flash, and html

Reply  
Thread Tools
adlamb's Avatar
Member with 152 posts.
 
Join Date: Nov 2004
Location: Manchester, England
Experience: I will never know enough!!
18-Nov-2009, 06:48 AM #1
Solved: Strange opening order on a page using java, flash, and html
This is a continuation of another thread but as the subject of the problem is now completely different, I decided it best to start another.

The code below loads a home page and (providing a cookie is not present) it loads a fullscreen black div with a container for a very short flash 'intro'. The Div then auto-closes after 4 seconds and therefore allows the flash to finish (as I couldn't find a way of linking the video end event to the closure of the div.) This is also quite good as it means that if there is a massive delay in the loading of the page, the video ends up not playing at all and so great for slow connections.

So, the problem, well for some reason, the black div seems to load after the rest of the page, particularly in Opera and Safari but sometimes in FF as well. This makes it look like you are being diverted away from the site just to watch a stupid 2.2 second video whereas I want it to seem like a small video to watch while the rest of the page loads behind.......?

I have just included the bottom part of the head and the top part of the body; and missed out the actual flash call for simplicity:

Code:
<script type="text/javascript">

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function setTheDivStyle() {
if(!readCookie('foxIndex')) {
// if cookie not found display the div and create the cookie
document.getElementById("splash").style.display="block";
createCookie('foxIndex', 'foxIndex', 24);  // 1 day = 24 hours persistence
}
else {
// if cookie found hide the div
document.getElementById("splash").style.display="none";
}
}
</script>	

<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>

</head>


<body onload = "setTheDivStyle()">

	<div id="splash">
	<div id="vid">
		<script>
		</script>
	</div>
	</div>

	<script type="text/javascript">
	function closeSplashDiv(){
	document.getElementById("splash").style.display=" none";
	}
	// close the div in 4 secs
	window.setTimeout( closeSplashDiv, 4000 );
	</script>

        <div id="container">.....................etc
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,637 posts.
 
Join Date: Oct 2006
20-Nov-2009, 05:10 PM #2
HTML Code:
<script type="text/javascript">

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function setTheDivStyle() {
if(!readCookie('foxIndex')) {
// if cookie not found display the div and create the cookie
document.getElementById("splash").style.display="block";
createCookie('foxIndex', 'foxIndex', 24);  // 1 day = 24 hours persistence
}
else {
// if cookie found hide the div
document.getElementById("splash").style.display="none";
}
}
</script>	

<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>

</head>


<body>

	<div id="splash">
	<div id="vid">
		<script>
		</script>
	</div>
	</div>

	<script type="text/javascript">
	setTheDivStyle()
	function closeSplashDiv(){
	document.getElementById("splash").style.display=" none";
	}
	// close the div in 4 secs
	window.setTimeout( closeSplashDiv, 4000 );
	</script>

        <div id="container">.....................etc
removed the call to setTheDivStyle from onload, put it in the <script> element.
adlamb's Avatar
Member with 152 posts.
 
Join Date: Nov 2004
Location: Manchester, England
Experience: I will never know enough!!
20-Nov-2009, 06:33 PM #3
Well, will you look at that!! It seems to have worked!!
There was me thinking that setting it in the body would force it to open first!
Is the explanation as to why this is not the case quick and easy?

Thanks so much for that! :-)
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,637 posts.
 
Join Date: Oct 2006
20-Nov-2009, 08:21 PM #4
adlamb's Avatar
Member with 152 posts.
 
Join Date: Nov 2004
Location: Manchester, England
Experience: I will never know enough!!
21-Nov-2009, 11:10 AM #5
Ah yes, I see now :-)
Thanks
One final thing, any idea why the div will not close in IE? I have found some mention of this online suggesting IE on XPSP2 could be a problem but don't understand enough to integrate the solution.....
http://support.microsoft.com/kb/884768
??
adlamb's Avatar
Member with 152 posts.
 
Join Date: Nov 2004
Location: Manchester, England
Experience: I will never know enough!!
24-Nov-2009, 05:29 AM #6
bump...
adlamb's Avatar
Member with 152 posts.
 
Join Date: Nov 2004
Location: Manchester, England
Experience: I will never know enough!!
01-Dec-2009, 06:20 AM #7
bump...
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,637 posts.
 
Join Date: Oct 2006
02-Dec-2009, 03:50 AM #8
Post link or attach full file.

what version of IE?

it works in other versions/browsers?
adlamb's Avatar
Member with 152 posts.
 
Join Date: Nov 2004
Location: Manchester, England
Experience: I will never know enough!!
02-Dec-2009, 04:16 AM #9
FF, opera, safari all work fine
IE 6, 7 and 8 do not. Its been driving me mad. I didn't want to add this splash page in the first page and now I wish I had just told my client no!
I will PM you the direct link if thats ok?
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,637 posts.
 
Join Date: Oct 2006
02-Dec-2009, 12:49 PM #10
that's fine
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,637 posts.
 
Join Date: Oct 2006
02-Dec-2009, 05:48 PM #11
you have a space before none:

document.getElementById("splash").style.display=" none";
adlamb's Avatar
Member with 152 posts.
 
Join Date: Nov 2004
Location: Manchester, England
Experience: I will never know enough!!
03-Dec-2009, 04:11 AM #12
I was bristling with excitement as I turned my PC on to get this reply and then rush through finding, opening, changing and testing this :-)

Thanks so much, now it's been pointed out, I cant believe how i didn't see that!

Thanks again for your help.
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:04 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.