SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2000
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Below is the tree menu on Microsoft's Scripting site, http://www.microsoft.com/scripting.

    Can someone tell me why this script won't work in NS?
    Seems to me it may be this: window.event.srcElement;
    Correct? I couldn't find window.event object in the NS
    DOM

    What would be a cross-browser solution to the code below?

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>
    &lt;STYLE type="text/css"&gt;
    &lt;!--
    BODY { BACKGROUND-ATTACHMENT: fixed ; font-family:Verdana, Arial;color:black;font-size="x-small"; margin-right:0; }
    DIV { font-family:Verdana, Arial, Helvetica; color:black; }
    .Outline { font-size:10pt; line-height:10pt; color:black; cursor:hand; text-decoration:none; font-weight:bold; }
    .Outline2 { font-size:8pt; line-height:8pt; color:black; cursor:hand; text-decoration:none; font-weight:bold; }
    .Topic { font-size:8pt; line-height:8pt; color:black; cursor:hand; text-decoration:none; font-weight:bold; }
    // --&gt;
    &lt;/STYLE&gt;

    &lt;script language="JavaScript" type="text/javascript"&gt;
    &lt;!-- hide this script from non-javascript-enabled browsers
    var img1, img2;
    img1 = new Image();
    img1.src = "../images/folder.gif";
    img2 = new Image();
    img2.src = "../images/ofolder.gif";

    function doOutline() {
    var targetId, srcElement, targetElement;
    srcElement = window.event.srcElement;
    if (srcElement.className == "Outline"&#0124; &#0124;srcElement.className == "Outline2") {
    srcElement = srcElement.id
    srcElement = srcElement.substr(0, srcElement.length-1);
    targetId = srcElement + "s";
    srcElement = srcElement + "i";
    srcElement = document.all(srcElement);
    targetElement = document.all(targetId);
    if (targetElement.style.display == "none") {
    targetElement.style.display = "";
    srcElement.src = "../images/ofolder.gif";
    }
    else {
    targetElement.style.display = "none";
    srcElement.src = "../images/folder.gif";
    }
    }
    }

    document.onclick = doOutline;
    document.onmouseover = doDocumentOnMouseOver ;
    document.onmouseout = doDocumentOnMouseOut ;

    // CHANGE HEADLINE COLOR ONMOUSEOVER

    function doDocumentOnMouseOver() {
    var eSrc = window.event.srcElement ;
    if (eSrc.className == "Outline"&#0124; &#0124;eSrc.className == "Topic"&#0124; &#0124;eSrc.className == "Outline2") {
    document.all(eSrc.id).style.color= "#FF0000"
    }
    }

    // CHANGE HEADLINE COLOR ONMOUSEOUT

    function doDocumentOnMouseOut() {
    var eSrc = window.event.srcElement ;
    if (eSrc.className == "Outline"&#0124; &#0124;eSrc.className == "Topic"&#0124; &#0124;eSrc.className == "Outline2") {
    document.all(eSrc.id).style.color= "#000000"
    }
    }
    // stop hiding --&gt;
    &lt;/script&gt;
    [/code]

  2. #2
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You need to read a little about Cross-Browser DHTML. Your code doesn't work in Netscape because it wasn't written for Netscape. Netscape doesn't recognize the document.all collection or several other aspects of your script. You should look at some tutorials by going to www.bratta.com or www.siteexperts.com, www.yasd.com, www.htmlguru.com or do a search on your favorite search engine. If you want cut and paste script then look at www.dynamicdrive.com or any javascript resource.

    A some books you can look into purchasing are called "DHTML Magic" and "Dynamic HTML" these both explain the concepts of cross-browser scripting quite well.

    ------------------
    Wayne Luke

    The Majormud Encyclopedia - www.bloodquest2.com
    Come Play one of the hottest games on the net.



  3. #3
    SitePoint Member
    Join Date
    Feb 2000
    Location
    Canada
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you got the code for the tree from a Microsoft site, then just a fast guess but knowing Microsoft and the way they seem to work, the only thing they care about is if it work right in their browers. So you your most likly going to have to do some fixing-up which could take alot time and reading if you don't know much about javascript or DHTML. You are better off just going for a cut in paste script and make sure it says that it works in both.


Bookmarks

Posting Permissions

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