Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    May 2004
    Posts
    391
    Thanks
    76
    Thanked 0 Times in 0 Posts

    object required?

    Why do I get object required?

    Code:
       <div id=layer1 style="visibility:hidden; position: absolute; top: 250; left: 20; width: 550; height: 100;  background-color: #FFFFFF; border: 2px dotted #6699FF; padding: 5px"></div>
    
    
    <script>
    function remove(removeId){
    
    	alert(removeId);
    };
    
    
    var emptyDiv = "layer1";
    
    var xx =" <span style='float:right'><a class='view' href='javascript:void(0)' onclick='remove("+emptyDiv+")'; return false;>Remove Report</a></span> ";
    
      document.getElementById(emptyDiv).style.visibility = 'visible';
      document.getElementById(emptyDiv).innerHTML = xx;
     
    
          
    </script>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,638 Times in 4,600 Posts
    I give up, why do you? I don't.

    I do have to ask why you wrote
    Code:
       .... onclick='remove("+emptyDiv+")'; ...
    That's kind of meaningless.

    It surely should have been
    Code:
       .... onclick='remove(emptyDiv)'; ...
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,638 Times in 4,600 Posts
    As your code is written, you would be callling
    Code:
    remove(layer1)
    There is no variable by that name, so when you end up doing
    Code:
       alert(removeId)
    you will either be doing the equivalent of alert(null) or, esp. in MSIE browsers, alert( the_object_with_the_id_of_layer1 ) (because MSIE treats IDs as object references if you don't override that meaning).
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    nikko50 (09-05-2012)

  • #4
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    947
    Thanks
    0
    Thanked 130 Times in 129 Posts
    Quote Originally Posted by Old Pedant View Post
    (because MSIE treats IDs as object references if you don't override that meaning).
    This behaviour is as far as I can see implemented in FF 15 too

  • Users who have thanked Lerura for this post:

    nikko50 (09-05-2012)

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,638 Times in 4,600 Posts
    Interesting. Didn't used to be. Wow. That's a big change.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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