onmouseover doesn't fire alert
Results 1 to 5 of 5

Thread: onmouseover doesn't fire alert

  1. #1
    Senior Member
    Join Date
    Aug 2009
    Posts
    365

    onmouseover doesn't fire alert

    I don't know why I don't get the alert message when I do a mouseover on the link.

    The link is for users to download a pdf.
    I want to alert them to know they will get a pdf if they click on the the link, when they mouseover the link they get a message pdf file to download
    The mouseover isn't happening?? The error says type error document.getElementById is null.

    This is my code.
    Code:
    <script type="text/javascript">
        document.getElementById('id').onmouseover = function() { alert('click to download pdf') } 
    </script>
    This is the anchor link
    <a href="white_papers/Monitoring_of_stem_cell.pdf" target="_blank" onMouseOver="this.id=''" id="stem_cell"
    >Monitoring of stem cell</a>
    THANKS!

  2. #2
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,432
    The <a> element you posted does not have an id of "id" (which is what your Javascript code is looking for).

  3. #3
    Senior Member
    Join Date
    Aug 2009
    Posts
    365
    I rewrote it but I get another error. Syntax missing formal parameter. Is the problem the anchor?
    Code:
    <script type="text/javascript">
        document.getElementById('id').onmouseover = download_hint;        
    function download_hint(id){id.alert("click to download pdf")};
    </script>
    <a href="white_papers/Monitoring_of_stem_cell.pdf" target="_blank" onMouseOver="this.id=''" id="stem_cell"
    >Monitoring of stem cell</a>

  4. #4
    Senior Member
    Join Date
    Aug 2009
    Posts
    365
    It still doesn't give the alert when I do the mouseover but I'm not getting any errors?IT just doesn't fire. Thanks,

    Code:
      var thisId=  document.getElementById('id'); 
              thisId.onmouseover  = download_hint;
            
    function download_hint(){alert("click to download pdf");}
    Code:
    div class="object">
    <object data="white_papers/sp6800/Chimerism_Analysis.pdf" type="application/pdf" width="100%" height="100%" > 
      <p>It appears you don't have a PDF plugin for this browser.
          Click here to download the pdf file.
      <a class="h3cal" href="data/Chimerism_Analysis.pdf">
      Chimerism Analysis </a></p>
    </object>
          <a class="h4cal" href="white_papers/sp6800/Chimerism_Analysis.pdf" target="_blank"   id="hla_antibody" >Chimerism Analysis </a>                               
    </div>

  5. #5
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,904
    The <a> element you posted does not have an id of "id" (which is what your Javascript code is looking for).
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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