www.webdeveloper.com
Results 1 to 3 of 3

Thread: Make Link Not Null

  1. #1
    Join Date
    Nov 2010
    Posts
    22

    Make Link Not Null

    How do I make this link not null? I'm getting a firebug error from it.
    Code:
    ajax.get(link.href + '&ajax=1', function(responce){

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    If you are doing a GET of an attribute and it's coming back as NULL or UNDEFINED, then there is nothing to get. Check the anchor tag to make sure that there is an HREF attribute (could it be a named anchor, with no HREF?)

  3. #3
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by WolfShade View Post
    If you are doing a GET of an attribute and it's coming back as NULL or UNDEFINED, then there is nothing to get. Check the anchor tag to make sure that there is an HREF attribute (could it be a named anchor, with no HREF?)
    There's a difference. null is an object. It is returned whenever something does not exist at all (undeclared). 'undefined' is a special value of the property typeof. It is return when something exists (it was declared), but it was not defined (has no assignment). But not always

    It is important when dealing with HTML attributes (DOM Attributes). They can be never 'undefined'. Either they are null, or they return their value.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script type="text/javascript">
    onload=function(){
    var div=document.getElementsByTagName('div')[0];
    alert(div.getAttribute('id')); // a non-existent native DOM Attribute is null
    alert(div.moo); // a non-existent native Property of an Object returns an empty string
    }
    </script>
    </head>
    <body>
    <div></div>
    </body>
    </html>
    But things changes in case of custom attributes/properties
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script type="text/javascript">
    onload=function(){
    var div=document.getElementById('foo');
    alert(div.getAttribute('moo')); // a non-existent custom DOM Attribute is null
    alert(div.moo); // a non-existent custom Property of an Object is undefined
    }
    </script>
    </head>
    <body>
    <div id="foo"></div>
    </body>
    </html>
    null, undefined, true, false - must be treated carefully, but they can also give us some extended information about the nature of that variable

    unemploymen, will you be kind and detail your problem? So far I guess you gave us insufficient information. Nor we can be sure either you are using JQyery (or other Framework) or you have created a custom method of your own called get().
    Last edited by Kor; 03-22-2011 at 06:34 AM.

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
  •  
HTML5 Development Center



Recent Articles