Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>javascript and layers

javascript and layers

mdcloud
03-18-2006, 12:42 AM
hey guys,

what i am doing is i have a navigation that i want to load in a layer but i need to be able to choose several different versions of the nav to load based on navigation. i can not seem to get them to load in the layer. all i get is the whole page to reload. can someone please help.

here is my code so far. i am a novice at javascript and am using a bit of code i found to create my layers and a different bit for the resolution redirect. apparently they dont mesh.

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</HEAD>
<body bgcolor="#FFCC33" text="#AF1F00" alink="#AF1F00" vlink="#AF1F00" link="#AF1F00">

<div id="Layer1" style="position:absolute; width:800px; height:800px; z-index:2; visibility: visible; left: 25px; top: 11px;">

<script language="JavaScript1.2">

if (screen.width==800||screen.height==600)
window.location.replace("secondnav800.html")

else if (screen.width==640||screen.height==480)
window.location.replace("secondnav600.html")

else if (screen.width==1024||screen.height==768)
window.location.replace("secondnav1024.html")

else
window.location.replace("secondnavother.html")

</script>

</div>

<div id="Layer2" style="position:absolute; width:800px; height:800px; z-index:1; visibility: visible;">

text

</div>

mdcloud
03-18-2006, 04:07 PM
what i need to know is what syntax to use in the

window.location.replace("secondnav1024.html")

the current code loads the html page but does by taking the whole thing to that page, not by just loading the html in the layer i need it to. what is the commands for doing this load?

please help

Kor
03-18-2006, 04:15 PM
you can not load a page into a layer. There are various methods to solve the problem, the simplier one is to use an iframe and load there the pages.
...
onload = function{
if (screen.width==800||screen.height==600)
document.getElementById('iframeid').setAttribute('src','secondnav800.html');
....
...
}
...



adjust the iframe's attribute (border 0 , no scroll, etc....) so that it could look like a part of the page.

mdcloud
03-18-2006, 04:25 PM
Thanks for the reply. i dont think i can use iframe though. i am needing my navigation to be able to expand over my text.

here is my working page without resolution sniffer

http://www.beinhealth.com/test/contact.html

when i tried to use iframe i couldnt get text to display under menu like i want. do you think i could set up my page to say something like

if (screen.width==800||screen.height==600)
display(my flash object code)

if so, what would be the command to display ()

thanks for your help... new to this but getting it i think

mdcloud
03-18-2006, 05:52 PM
ok, i have been trying to figure out how to make my last post work.

here is what i got

else if (screen.width==1024||screen.height==768)
document.write("<OBJECT classid=" + "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" + "codebase=" + "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
+ "WIDTH=" + "1000" + "HEIGHT=" + "300" + "id=secondnav ALIGN=top>" +
"<PARAM NAME=movie VALUE=http://codingforums.com/archive/index.php/secondnav.swf> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=transparent> <PARAM NAME=bgcolor VALUE=#FFCC33> <EMBED src=http://codingforums.com/archive/index.php/secondnav.swf quality=high wmode=transparent bgcolor=#FFCC33 WIDTH=" + "1000" + "HEIGHT=" + "300" + "NAME=secondnav ALIGN=top TYPE=application/x-shockwave-flash PLUGINSPAGE=" + "http://www.macromedia.com/go/getflashplayer" + "></EMBED> </OBJECT>" + ")")


basicly all the stuff in red is my flash object. everywhere in the flash object code there was a "" i had to go in and add a " + " to get it to read out with no errors. now it displays... yea! but it is about 1/4 size and i dont know why. i am sure there is a better way of doing this. is there a way to get the whole object code to display without having to break it up?

mdcloud
03-18-2006, 06:41 PM
ok,

i GOT IT !!!

here is the code i got to work. if you guys see anything i did wrong please let me know. as far as i know this is working correctly, but as i have said i am new to this

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</HEAD>
<body bgcolor="#FFCC33" text="#AF1F00" alink="#AF1F00" vlink="#AF1F00" link="#AF1F00">

<div id="Layer1" style="position:absolute; width:1200px; height:800px; z-index:2; visibility: visible; left: 25px; top: 11px;">

<script language="JavaScript1.2">

if (screen.width==640||screen.height==480)
document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="600" HEIGHT="200" id="secondnav600" ALIGN="top"> <PARAM NAME=movie VALUE=http://codingforums.com/archive/index.php/"secondnav600.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=transparent> <PARAM NAME=bgcolor VALUE=#FFCC33> <EMBED src=http://codingforums.com/archive/index.php/"secondnav600.swf" quality=high wmode=transparent bgcolor=#FFCC33 WIDTH="600" HEIGHT="200" NAME="secondnav600" ALIGN="top" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED> </OBJECT>')

else if (screen.width==800||screen.height==600)
document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="800" HEIGHT="300" id="secondnav800" ALIGN="top"> <PARAM NAME=movie VALUE=http://codingforums.com/archive/index.php/"secondnav800.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=transparent> <PARAM NAME=bgcolor VALUE=#FFCC33> <EMBED src=http://codingforums.com/archive/index.php/"secondnav800.swf" quality=high wmode=transparent bgcolor=#FFCC33 WIDTH="800" HEIGHT="300" NAME="secondnav800" ALIGN="top" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></object>')



else if (screen.width==1024||screen.height==768)
document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="1000" HEIGHT="300" id="secondnav" ALIGN="top"> <PARAM NAME=movie VALUE="http://codingforums.com/archive/index.php/secondnav.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=transparent> <PARAM NAME=bgcolor VALUE=#FFCC33> <EMBED src="http://codingforums.com/archive/index.php/secondnav.swf" quality=high wmode=transparent bgcolor=#FFCC33 WIDTH="1000" HEIGHT="300" NAME="secondnav" ALIGN="top" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED> </OBJECT>')

else
document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="1200" HEIGHT="400" id="secondnavother" ALIGN="top"> <PARAM NAME=movie VALUE=http://codingforums.com/archive/index.php/"secondnavother.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=transparent> <PARAM NAME=bgcolor VALUE=#FFCC33> <EMBED src=http://codingforums.com/archive/index.php/"secondnavother.swf" quality=high wmode=transparent bgcolor=#FFCC33 WIDTH="1200" HEIGHT="400" NAME="secondnavother" ALIGN="top" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>')

</script>

</div>

<div id="Layer2" style="position:absolute; width:800px; height:800px; z-index:1; visibility: visible;">

text

</div>

Came out pretty good. to see example go to

http://www.beinhealth.com/test/contact.html


 

TOP

Hyperthreading hurts s
HP sharpens blade PC l
Apple goes for Quad po
Itanium gets scaled do

For more info

HP sharpens blade PC l
Hyperthreading hurts s
can not call click() i
script does not work o
smart menu 
write to an html file 
FireFox doesn't recogn
Changing e.keyCode (e.
Clearing a range creat
UPDATE: My mouse over 

News Archive

onChange Help 
beforeload? vs onload.
Problem with document.
decreasing my javascri
Problem with \\ and \ 
how to stop scrolling?
Change Label Text Colo
Can I forward a page b
2 javascript functions
Validating a textbox 

Related stories:

Multiple functions with "onload" does not work.
Form code that puts a price relative to an item # in another field
Forcing User to Scroll through Text Box
Confirm delete in href of display:column tag
onChange="submit()" for select only works once
Pop Up Javascript
Call function when user closes browser
Disabling F1, F3, etc. default actions
Link to root

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics