SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Location
    U.A.E.
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with Mozilla

    Hi

    i have a simple script, its work fine with IE, and there is a problem with
    Mozilla "or other Gecko based browsers" here is the scirpt:
    Code:
    <html>
    <head>
    <script>
    function showMe(val) { 
         document.all.showhide.innerText=val; 
    } 
    </script>
    </head>
    <body topmargin="0" leftmargin="0" rightmargin="0">
    <p><a href="#" onmouseover="showMe('Test')" onmouseout="showMe('')">Show</a></p>
    <p id="showhide"></p>
    </body>
    </html>
    so, whats wrong with this script?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Your "Problem" is that document.all is IE-only. Try out this instead, which should work in Gecko and IE. However, you should also know that innerText and innerHTML are not supported by all browsers. It's not standard DOM:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function showMe(val) { 
    	 document.getElementById("showhide").innerText=val; 
    } 
    </script>
    </head>
    <body topmargin="0" leftmargin="0" rightmargin="0">
    <p><a href="#" onmouseover="showMe('Test')" onmouseout="showMe('')">Show</a></p>
    <p id="showhide"></p>
    </body>
    </html>

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Location
    U.A.E.
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks

    but still not working with mozilla.

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Oops, I left an extra space in the javascript function! Try this below:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function showMe(val) { 
    document.getElementById("showhide").innerText=val; 
    } 
    </script>
    <style type="text/css">
    body {
    margin:0px;
    }
    </style>
    </head>
    <body>
    <p><a href="#" onmouseover="showMe('Test');" onmouseout="showMe('');">Show</a></p>
    <p id="showhide"></p>
    </body>
    </html>
    EDIT: Apparently vbulletin puts an extra space in the parentheses of the javascript function (in the document.getElementById). Try copying this script and pasting it into your text editor, then removing that extra space and see if your script works.

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Location
    U.A.E.
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by vgarcia
    Oops, I left an extra space in the javascript function! Try this below
    there is no problem with the code, its just not compatible wit Mozilla

    anyway, thanks millions

  6. #6
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try innerHTML instead of innerText

    good ol' Moz, he he

  7. #7
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Location
    U.A.E.
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MikeFoster: WOW! Thanks ...
    now its work with mozilla


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
  •