Javascript issues with Mozilla

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • danielji
    New Member
    • Dec 2007
    • 10

    Javascript issues with Mozilla

    Hi, I'm having trouble with my javascript in Mozilla. I'm trying to use onClick within a link to call hidden divs in page. This seems to function properly in IE and Safari but not Mozilla. I would appreciate any feedback.


    javascript in header:

    [HTML]<script language="javas cript">
    <!--

    function changeLinks(lin k) {


    if (link=="1") {

    window.LinksInt ernal.style.dis play = '';
    window.LinksExt ernal.style.dis play = 'none';
    window.LinksQui ck.style.displa y = 'none';

    }

    if (link=="2") {

    window.LinksInt ernal.style.dis play = 'none';
    window.LinksExt ernal.style.dis play = '';
    window.LinksQui ck.style.displa y = 'none';

    }

    if (link=="3") {

    window.LinksInt ernal.style.dis play = 'none';
    window.LinksExt ernal.style.dis play = 'none';
    window.LinksQui ck.style.displa y = '';

    }

    </head>
    [/HTML]
    code in body:

    [HTML]
    <a onClick="change Links(3);return false;" style="cursor:h and"><img border="0" src="/images/quicklinks3.gif " class="right" ></a><a onClick="change Links(2);return false;" style="cursor:h and"><img border="0" class="right" src="/images/externallinks3. gif" ></a> <a onClick="change Links(1);return false;" style="cursor:h and"><img border="0" class="right" src="/images/internallinks3. gif" ></a><BR>[/HTML]
    Last edited by gits; Dec 19 '07, 09:03 PM. Reason: added code tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    hi ...

    welcome to TSDN ...

    try to use:

    [CODE=javascript]window.LinksInt ernal.style.dis play = 'block';[/CODE]
    instead of setting it to an empty string :)

    kind regards

    Comment

    • Dasty
      Recognized Expert New Member
      • Nov 2007
      • 101

      #3
      And fix referencing too, because it is invalid. Make it this way:
      Code:
      document.getElementById('LinksInternal').style.display = '';

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        Originally posted by Dasty
        And fix referencing too, because it is invalid. Make it this way:
        [CODE=javascript]
        document.getEle mentById('Links Internal').styl e.display = '';[/CODE]
        yup ... of course ... and ensure you have the corresponding id set to the node ...

        kind regards

        Comment

        • danielji
          New Member
          • Dec 2007
          • 10

          #5
          Hi Friends, thank you for the prompt replies. I've tried both your recommendations and am still having trouble except this time it's not working in IE either.

          [HTML]function changeLinks(lin k) {


          if (link=="1") {

          document.getEle mentByID('Links Internal').styl e.display = '';
          document.getEle mentByID('Links External').styl e.display = 'none';
          document.getEle mentByID('Links Quick').style.d isplay = 'none';

          }

          if (link=="2") {

          document.getEle mentByID('Links Internal').styl e.display = 'none';
          document.getEle mentByID('Links External').styl e.display = '';
          document.getEle mentByID('Links Quick').style.d isplay = 'none';


          }

          if (link=="3") {

          document.getEle mentByID('Links Internal').styl e.display = 'none';
          document.getEle mentByID('Links External').styl e.display = 'none';
          document.getEle mentByID('Links Quick').style.d isplay = '';


          }


          }
          [/HTML]

          called via onClick here:
          [HTML]
          <div id="LinksContai ner" >
          <a onClick="change Links(3);return false;" style="cursor:h and"><img border="0" src="/images/quicklinks3.gif " class="right" ></a><a onClick="change Links(2);return false;" style="cursor:h and"><img border="0" class="right" src="/images/externallinks3. gif" ></a> <a onClick="change Links(1);return false;" style="cursor:h and"><img border="0" class="right" src="/images/internallinks3. gif" ></a><BR>

          <% Call fn_getLinksExte rnal(2) %>
          <% Call fn_getLinksInte rnal(2) %>
          <% Call fn_getLinksQuic k(2) %>


          </div>[/HTML]
          Last edited by gits; Dec 19 '07, 09:48 PM. Reason: added code tags

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5388

            #6
            getElementById ... note that javascript is case-sensitive

            kind regards

            Comment

            • danielji
              New Member
              • Dec 2007
              • 10

              #7
              Originally posted by gits
              getElementById ... note that javascript is case-sensitive

              kind regards
              works now, many many thanks for catching that!

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5388

                #8
                no problem ... glad to hear you got it working :) ... post back to the forum anytime you have more questions

                kind regards

                Comment

                Working...