Results 1 to 11 of 11

Thread: heres a switch

  1. #1
    scoutt
    Guest

    heres a switch

    ok everybody knows that IE does things that NS doesn't. so I have a switch for ya. I have this script that makes popup tips on the mouse. know on the first page both works great, but when I go to another page IE gives an error but NS works great. here is the script and the bold is the error in IE.
    the error is "skn is null or not an object"
    Code:
    <DIV ID="dek" CLASS="dek"></DIV>
    <SCRIPT TYPE="text/javascript">
    <!--
    
    /*
    Pop up information box II (Mike McGrath ([email protected],  http://website.lineone.net/~mike_mcgrath))
    Permission granted to Dynamicdrive.com to include script in archive
    For this and 100's more DHTML scripts, visit http://dynamicdrive.com
    */
    
    Xoffset=-40;    // modify these values to ...
    Yoffset= 20;    // change the popup position.
    
    var nav,old,iex=(document.all),yyy=-1000;
    if(navigator.appName=="Netscape"){(document.layers)?nav=true:old=false;}
    
    if(!old){
    var skn=(nav)?document.dek:dek.style;
    if(nav)document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove=get_mouse;
    }
    
    function poptip(msg,bak){
    var content="<TABLE  WIDTH=125 BORDER=1 BORDERCOLOR=black CELLPADDING=2 CELLSPACING=0 "+
    "BGCOLOR="+bak+"><TD align=center><FONT COLOR=black SIZE=2>"+msg+"</FONT></TD></TABLE>";
    if(old){alert(msg);return;} 
    else{yyy=Yoffset;
     if(nav){skn.document.write(content);skn.document.close();skn.visibility="visible"}
     if(iex){document.all("dek").innerHTML=content;skn.visibility="visible"}
     }
    }
    
    function get_mouse(e){
    var x=(nav)?e.pageX:event.x+document.body.scrollLeft;skn.left=x+Xoffset;
    var y=(nav)?e.pageY:event.y+document.body.scrollTop;skn.top=y+yyy;
    }
    
    function kill(){
    if(!old){yyy=-1000;skn.visibility="hidden";}
    }
    
    //-->
    </SCRIPT>
    the only different is that on the other page I have another menu tha tis the same on the first. but the other page has 2 of them.

    any Ideas??

  2. #2
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Where is your variable "old" being set if the browser is IE? I can see it being set for Navigator.

    if(navigator.appName=="Netscape"){(document.layers)?nav=true old=false;}

    Is this line ever reached if the browser is IE?


    var skn=(nav)?document.dek:dek.style;

    Meaning skn is not set for IE...
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  3. #3
    scoutt
    Guest
    that is just it, I don't think it is being set for IE. I am not sure if that line gets reached or not. how can you tell? it is funny if you turn old to flase it still works in NS4.x but if you turn it true it gives a error message in NS6, so I leave it false.

  4. #4
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    How about adding this line:

    if(navigator.appName=="Netscape"){(document.layers)?nav=true old=false;}
    if(iex){
    var skn=dek.style;
    old = true;
    }
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  5. #5
    scoutt
    Guest
    I must have put that in the wrong spot, because I tried that one before and it didn't do anything,

    But this time I used it and it got rid of the error but it gives me a popup box and I have to hit ok everytime. it is suppose to be a tooltip box.

  6. #6
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    That would be this line firing:

    if(old){alert(msg);return;}
    else{yyy=Yoffset;
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  7. #7
    scoutt
    Guest
    that is right. that is why I have to put old=false for NS6 so it doesn't fire that line. but if I make old=false for ie then it comes back with that error.

    but why does it work fine when it is on the first page with only one menu but on the other pages that have 2 menus then it comes back with the error.

  8. #8
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Are you changing the <DIV> ID's in the code and in the DIV tag for each DIV?

    To have more than one each of these must have separate ID's.

    <DIV ID="dek" CLASS="dek"></DIV>
    <DIV ID="dek1" CLASS="dek1"></DIV>

    Anywhere in the script that references these ID's would have to be changed as well.

    I didn't go through the script but from what I read it looks like it's designed for only one popup. To make it work for more than one you'd have to pass in the ID's and use varaibles in the script.

    Have you tried changing this line to:
    if(old){return;}
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  9. #9
    scoutt
    Guest
    ok I only planned on using it for 1 menu. I tried to change wha tyou suggested but it didn't even popup anything. not all my pages use the second menu. well go here and see what I mean.
    www.motorcycleridersassoc.org

    just from the first page it works but if you go to information page and you can see teh other menu. I didn't change any div tag because I only planned on it for one menu. so I thought since I had 2 I would just set it up for the other.

  10. #10
    scoutt
    Guest
    actually I think I fixed it. I just made another script the same as the one that is being called from the first page then just renamed it for the different menus. now it works just fine.

    thanks chris for all your help

  11. #11
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    No problem

    Glad things worked out...
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width