SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    works in IE (pop_up message) how to make it working Mozila?

    There is a code it works in IE (pop_up message)
    how to make it working Mozila?
    Code:
    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    <!--
    function ShowHelp(div, title, desc)
    {
     div.style.display = 'inline';
     div.style.position = 'absolute';
     div.style.width = '100';
     div.style.backgroundColor = 'lightyellow';
     div.style.border = 'solid 1px black';
     div.style.padding = '4px';
     div.style.color = '#000000';
     div.style.font = 'x-small serif';
     div.innerHTML = '<div><b>' + title + '</b></div><div style="padding-left:5; padding-right:4">' + desc + '</div>';
    }
    function HideHelp(div)
    {
     div.style.display = 'none';
    }
    //-->
    </SCRIPT>
    <img src="img/icon_shedule_event.gif" width="12" height="14" alt="" border="0"
    onmouseover="ShowHelp(d1, 'blah', 'blah')" 
    onmouseout="HideHelp(d1)">
    <DIV id=d1 style="DISPLAY: none"></DIV>

  2. #2
    SitePoint Addict xDev's Avatar
    Join Date
    Jul 2003
    Location
    Moncton, New Brunswick, Canada
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The proper way to access an element is with the DOM: document.getElementById()

    var div = document.getElementById(div);

    You now have a cross-browser solution.

    HTML Code:
    <html>
    <head>
    <title>Test</title>
    <script type="text/javascript">
    function ShowHelp(div, title, desc)
    {
      var div = document.getElementById(div);
     div.style.display = 'inline';
     div.style.position = 'absolute';
     div.style.width = '100';
     div.style.backgroundColor = 'lightyellow';
     div.style.border = 'solid 1px black';
     div.style.padding = '4px';
     div.style.color = '#000000';
     div.style.font = 'x-small serif';
     div.innerHTML = '<div><b>' + title + 
      '</b></div><div style="padding-left:5; padding-right:4">' 
      + desc + '</div>';
    }
    function HideHelp(div)
    {
     document.getElementById(div).style.display = 'none';
    }
    </script>
    </head>
    <body>
    <img src="img/icon_shedule_event.gif" width="12" height="14" alt="" border="0"
    onmouseover="ShowHelp('d1', 'blah', 'blah')" 
    onmouseout="HideHelp('d1')">
    <div id="d1" style="display: none"></div>
    </body>
    </html>
    I also put quotes around the id parameter passed to the function:
    onmouseover="ShowHelp('d1', 'blah', 'blah')"
    onmouseout="HideHelp('d1')">
    <div id="d1" style="display: none"></div>

    Cause it's a string and in the html you should always quote your attributes especially when using javascript to access an id.

    -xDev

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I'll try.

    Do you know why this does not working in Mozilla
    if(document.employee_form.not_change_pass.checked == false) {
    ....


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
  •