PDA

View Full Version : floating menu on FF vs. IE



brunch43
03-28-2006, 09:49 PM
ok, so im using a switch menu embedded in a floating menu and for some reason it doesnt work on IE, heres the code, the links arent done yet so thats why they may look strange....

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<!-- saved from url=(0014)about:internet -->
<!-- this and above comment should be removed for live, non-demo use -->
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="robots" content="noindex,nofollow">

<link rel="stylesheet" href="stylesheet.css" type="text/css" />
<title>MTD: Mysteriously Transmitted Diseases</title>

<script type="text/javascript">

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1",

id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj, addr){
if(document.getElementById){
if (obj!=0)var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
if(obj==0 || el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
if (obj!=0)el.style.display = "block";
}else{
if (obj!=0)el.style.display = "none";
}
}
if (addr) parent.location.href=addr
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate




function getDocHeight(doc) {
var docHt = 0, sh, oh;
if (doc.height) docHt = doc.height;
else if (doc.body) {
if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
if (sh && oh) docHt = Math.max(sh, oh);
}
return docHt;
}

function setIframeHeight(iframeName) {
var iframeWin = window.frames[iframeName];
var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
if ( iframeEl && iframeWin ) {
iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous
var docHt = getDocHeight(iframeWin.document);
// need to add to height to be sure it will all show
if (docHt) iframeEl.style.height = docHt + 30 + "px";
}
}

function loadIframe(iframeName, url) {
if ( window.frames[iframeName] ) {
window.frames[iframeName].location = url;
return false;
}
else return true;
}
</script>
</head>
<body>


<!-------- Begin #content --------->

<div id="content">

<!-------- Header ---------->

<div id="header">
<div>

<h1>

MTD: Mysteriously Transmitted Diseases

</h1>

</div>
</div>

<!------- Begin #main ------->


<div id="main">
<iframe name="ifrm" id="ifrm" src="about.html" width="480" height="600" scrolling="no" frameborder="0">Sorry, your browser

doesn't support iframes.</iframe>
</div>

<!------- End #main ------->





<div id="sidebar">

<p>

<script>
if (!document.layers)
document.write('<div id="divStayTopLeft" style="position:absolute">')
</script>

<layer id="divStayTopLeft">


<!-- Begin menu-->



<div id="masterdiv">

<div class="menutitle" onclick="SwitchMenu('sub1')">Home</div>
<span class="submenu" id="sub1">
<table bgcolor=blue border=0 width=210px>
<tr>
<td><a href="about.html" onclick="return loadIframe('ifrm', this.href)">Welcome</a><br>
</td>

</tr>
<tr>
<td><a href="http://www.yahoo.com">About</a><br>
</td>

</tr>
</table>

</span>



<div class="menutitle" onclick="SwitchMenu('sub2')">Top Ten List</div>
<span class="submenu" id="sub2">

<table bgcolor=blue border=0 width=210px>
<tr>
<td><a href="http://www.fiu.edu">AIDS</a><br>
</td>
</tr>

<tr>
<td><a href="http://www.yahoo.com">Herpes</a><br>
</td>
</tr>

<tr>
<td><a href="help.htm">Hepatitis</a>
</td>
</tr>

</table>


</span>

<div class="menutitle" onclick="SwitchMenu('sub3')">Prevention Toolkit</div>
<span class="submenu" id="sub3">
<table bgcolor=blue border=0 width=210px>
<tr>
<td><a href="notice.htm">Condoms</a><br>
</td>

</tr>
<tr>
<td><a href="faqs.htm">Spremicides</a><br>
</td>

</tr>
<tr>
<td><a href="help.htm">Safe Sex Guidelines</a>
</td>
</tr>

</table>
</span>

<div class="menutitle" onclick="SwitchMenu('sub4')">Help Center</div>
<span class="submenu" id="sub4">

<table bgcolor=blue border=0 width=210px>
<tr>
<td><a href="notice.htm">Treatment Centers</a><br>
</td>

</tr>
<tr>
<td><a href="faqs.htm">Other Resources</a><br>
</td>

</tr>



</table>
</span>



</div>

</layer>


<!--END OF MENU-->


</layer>





<script type="text/javascript">

/*
Floating Menu script- Roy Whittle (http://www.javascript-fx.com/)
Script featured on/available at http://www.dynamicdrive.com/
This notice must stay intact for use
*/

var verticalpos="fromtop"

if (!document.layers)
document.write('</div>')

function JSFX_FloatTopDiv()
{
var startX = 133,
startY = 109;
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function ml(id)
{
var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.left=x;this.style.top=y;};
el.x = startX;
if (verticalpos=="fromtop")
el.y = startY;
else{
el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
el.y -= startY;
}
return el;
}
window.stayTopLeft=function()
{
if (verticalpos=="fromtop"){
var pY = ns ? pageYOffset : document.body.scrollTop;
ftlObj.y += (pY + startY - ftlObj.y)/8;
}
else{
var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
ftlObj.y += (pY - startY - ftlObj.y)/8;
}
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopLeft()", 10);
}
ftlObj = ml("divStayTopLeft");
stayTopLeft();
}
JSFX_FloatTopDiv();
</script>

</div>

</div>

<!------- End #sidebar ------->

<!------- Begin #footer ------->

<div id="footer">
<div>
<div>

<p>yes, i think we're done here......................uh...<i>hello</i>??did someone say granola &nbsp;</p>

</div>
</div>
</div>

<!------- End #footer ------->

</div>

<!------- End #content ------->

</body>
</html>