www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 11-04-2009, 09:56 AM
    java49768 java49768 is offline
    Registered User
     
    Join Date: Jul 2008
    Posts: 18
    Null or Not an Object in IE

    OK have the following function in my code:
    Code:
    function newhslide() {
    	if (h == hnumslides) h = 0;
    	h++;
    	document.images['hslide'].src = hpiclist[h];
    	document.links['hsurl'].href = hpicurl[h];
    }
    My html looks like this:
    Code:
    <a href="javascript:void(0);" id="hsurl">
    <img alt="header slide" name="hslide" src="images/cartpics/hometop.jpg" height="366" width="700" border="0">
    </a>
    Now I've got everything set up (array's for hpiclist and hpicurl, etc.) and this is being used as a slideshow. The reason for the void(0) is because only some of the slides are clickable to send you to differrent pages in the site. The first happens to be just a pic and the second has a link. So in my hpicurl array I have the voids for all of the slides that don't need to go anywhere and have an actual link to another page in my site for the one's that do. And of course all of this is working perfectly in Firefox like it always does. However, in IE the line
    Code:
    document.links['hsurl'].href = hpicurl[h];
    is giving me the error:

    'document.links.hsurl' is null or not an object

    I know I'm missing something simple here, but as usual with IE not sure what it is. Any help please?

    Last edited by java49768; 11-04-2009 at 10:42 AM. Reason: Explain a bit further
    Reply With Quote
      #2  
    Old 11-04-2009, 10:59 AM
    Kor's Avatar
    Kor Kor is offline
    Red Devil Moderator
     
    Join Date: Dec 2003
    Location: Bucharest, ROMANIA
    Posts: 11,142
    id and name are different things.

    The classical old syntax
    Code:
    document.links['hsurl']
    needs a name for your link, not an id.
    Reply With Quote
      #3  
    Old 11-04-2009, 02:28 PM
    java49768 java49768 is offline
    Registered User
     
    Join Date: Jul 2008
    Posts: 18
    Thanks for the replay, but
    Code:
    <a href="javascript:void(0);" name="hsurl">
    is what I originally had and it doesn't work either. I had just forgotten to change it back before I posted this. My current code has it with name and not id and I get the same error. Any other thoughts?
    Reply With Quote
      #4  
    Old 11-04-2009, 02:32 PM
    jasonahoule's Avatar
    jasonahoule jasonahoule is offline
    Registered User
     
    Join Date: Mar 2007
    Location: Orlando
    Posts: 659
    Why not use document.getElementById('hsurl').href instead?
    __________________
    Jason
    Portfolio
    Blog
    Reply With Quote
      #5  
    Old 11-04-2009, 03:09 PM
    java49768 java49768 is offline
    Registered User
     
    Join Date: Jul 2008
    Posts: 18
    Unbelievable! Man I hate IE. The way I had it with name was fine provided I didn't use the brackets [ ]. I changed it to parentheses () and it worked in IE. But now Firefox didn't like it. I had tried jasonahoule's suggestion before as one of my tests but I used the [] and of course IE didn't like that. Now using the () instead, it of course worked perfectly in both IE and Firefox. Did I mention I hate IE?

    Thanks so much, this has been such a frustrating modification when it only took a few minutes to write in the first place and worked in the only Browser that I'll ever use. Too bad I can't convince everyone else to stop using IE... lol. Thanks again guys!
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:44 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.