Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,536 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,259 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Drop down menu issue in IE

 
Reply to this topicStart new topic

Drop down menu issue in IE

BenignDesign
post 17 Jul, 2008 - 07:50 AM
Post #1


Dorkerella

Group Icon
Joined: 28 Sep, 2007
Posts: 829



Thanked 2 times

Dream Kudos: 150
My Contributions


I am working on a site (live demo here).

The problem is there is supposed to be a drop-down menu under "Services". It works without a problem in FF, it works without a problem in IE IF I load it from a local file. When loading from the live demo, the drop down only appears in IE after clicking on "HOME".

Here is my HTML (scaled down):
HTML
<html>
<head>
<title>Women's Help Center</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style_ie.css" />
<![endif]-->
<script src="hover.js" type="text/javascript" language="javascript"></script>
<!--[if IE 7]>
<script defer type="text/javascript" src="pngfix.js"></script>
<![endif]-->
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="ph_num">TOLL FREE 1-800-999-7406 (PA ONLY)</div>
<div id="logo"><img src="gfx/logo.png" style="height:243px;width:509px;" /></div>
<div id="th_yr"><img src="gfx/thirty.png" style="height:235px;width:530px;" /></div>
</div>

<div id="navigation">
<table width="1100" height="215" border="0" align="center" cellpadding="0" cellspacing="0" id="menu" style="margin-top:-29px;">

<tr><td height="215" align="right" valign="top"><ul id="nav">

<li><a href="index.html"> <font color=#f99544>HOME</font> <!--[if IE 7]> <![endif]--><font color=#9ccacd>|</font><!--[if IE 7]> <![endif]--> </a></li>

<li><a href="#">SERVICES <!--[if IE 7]> <![endif]--><font color=#9ccacd>|</font><!--[if IE 7]> <![endif]--> </a><ul>
<li><a href="serv_environ.html" rel="nofollow"><font size=3><!--[if IE 7]><font size=4><![endif]-->Emergency Shelter</font></a></li>
<li><a href="serv_coal.html" rel="nofollow"><font size=3><!--[if IE 7]><font size=4><![endif]-->Information & Referral</font></a></li>
<li><a href="serv_area.html" rel="nofollow"><font size=3><!--[if IE 7]><font size=4><![endif]-->Legal Advocacy</font></a></li>
</ul></li>

<li><a href="#">PROGRAMS <!--[if IE 7]> <![endif]--><font color=#9ccacd>|</font><!--[if IE 7]> <![endif]--> </a></li>

<li><a href="#">COUNSELING <!--[if IE 7]> <![endif]--><font color=#9ccacd>|</font><!--[if IE 7]> <![endif]--> </a></li>

<li><a href="#">CONTACT<font color=#ffffffsneaky.gif/font>US</a></li>

</ul></td></tr></table>
</div>

.
.
.
.
.
</body>
</html>


and the javascripts listed in the header:

hover.js:
CODE

sfHover = function() {
    var sfEls = document.getElementById("nav").getElementsByTagName("LI");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onmouseover=function() {
            this.className+=" sfhover";
        }
        sfEls[i].onmouseout=function() {
            this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


pngfix.js (is supposed to correctly render png images in IE):
CODE

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (document.body.filters))
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}


Any ideas why I'm having this problem and/or how I can fix it?? Many thanks!
User is offlineProfile CardPM

Go to the top of the page


BetaWar
post 17 Jul, 2008 - 12:46 PM
Post #2


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,266



Thanked 38 times

Dream Kudos: 775
My Contributions


Okay, I have gotten it to work in IE 6, and I think it will work in IE 7, but all I did differently if place the js howev code inside of the HTML instead of linking to it via the script tags.

One other issues that I have noticed if that you state <!--[if IE 7]> which means that IE 6 does not get the .png transparecy, you may want to just say <!--[if IE]> without specifying a version since the JS checks for version and compatability in it already.

I am still looking for a why to get it to work with linked script.

Hope tha thelps.
User is online!Profile CardPM

Go to the top of the page

BenignDesign
post 17 Jul, 2008 - 06:23 PM
Post #3


Dorkerella

Group Icon
Joined: 28 Sep, 2007
Posts: 829



Thanked 2 times

Dream Kudos: 150
My Contributions


It was a great idea, but alas, it is not functioning in IE7 at all now. Back to the drawing board, I suppose. sad.gif

Thanks for the reply!!! If you find a solution, PLEASE pass it along!
User is offlineProfile CardPM

Go to the top of the page

BetaWar
post 18 Jul, 2008 - 10:39 AM
Post #4


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,266



Thanked 38 times

Dream Kudos: 775
My Contributions


Okay, at this point I think I have created a basic version of what you already have, it works in IE 6, but I hven't tested it in IE 7 yet. Here is the code:

CODE
<style>
.menu{
  line-style: none;
}
.menu .over, .menu .out{
  float: left;
}
.out{
  background: #9999ff;
}
.menu .out .submenu{
  display: none;
}
.over{
  background: #99ff99;
}
.menu .over .submenu{
  display: block;
}
.submenu{
  position: absolute;
  left: 10px;
  top: 33px;
  border: 1px solid #333;
  background: #ffffff;
}
.submenu li{
  list-style: none;
  display: block;
}
</style>

<script>
onerror=handleErr;
var txt="";
function handleErr(msg,url,l){
  txt="There was an error on this page.\n\n";
  txt+="Error: " + msg + "\n";
  txt+="URL: " + url + "\n";
  txt+="Line: " + l + "\n\n";
  txt+="Click OK to continue.\n\n";
  alert(txt);
  return true;
}

  function tload(id){
    nid = document.getElementById(id);
    nid.onmouseover = function(){
      this.className = "over";
    }
    nid.onmouseout = function(){
      this.className = "out";
    }
  }
</script>

<body onload="tload('support');">

<ul class="menu">
  <li class="out" id="support">TSET
    <ul class="submenu">
      <li>Item 1</li>
      <li>Item 2</li>
    </ul>
  </li>
  <li class="out">
    TSET 2
  </li>
</ul>
User is online!Profile CardPM

Go to the top of the page

BenignDesign
post 22 Jul, 2008 - 08:46 AM
Post #5


Dorkerella

Group Icon
Joined: 28 Sep, 2007
Posts: 829



Thanked 2 times

Dream Kudos: 150
My Contributions


Thanks ever so much for all you work to help me out! I solved the problem... and it turns out the issue wasn't with the actual menu at all.... it was in loading my .png images. I set up a preloader to take care of the images and now the menu loads without an issue. Again, many, many thanks!
User is offlineProfile CardPM

Go to the top of the page

BetaWar
post 22 Jul, 2008 - 10:48 AM
Post #6


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,266



Thanked 38 times

Dream Kudos: 775
My Contributions


No problem, glad to see you were able to find the solution smile.gif
User is online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/7/08 09:42PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month