Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6018991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:21:20+00:00 2026-05-23T03:21:20+00:00

In this slightly lengthy code snippet: (function() { var element = function(str) { return

  • 0

In this slightly lengthy code snippet:

(function() {
    var element = function(str) {
        return document.getElementById(str);
        },

        parent = document.getElementsByTagName('ul')[0].getElementsByTagName('li'),
        len = parent.length,

        swap_slide = function(slide){
            return function(event) {
                event.preventDefault ? event.preventDefault() : event.returnValue = false;
                
                var slides = element('main').getElementsByTagName('div'),
                    len = slides.length;
                for (var i=0; i<len; i++) {
                    slides[i].style.display = 'none';
                }
                slide.style.display = 'block';
            }
        };

    for (var i=0; i<len; i++) {
        var link = parent[i].getElementsByTagName('a')[0],
            slide = element(parent[i].getElementsByTagName('a')[0].getAttribute('href').substr(1));

        if (link.addEventListener) {
            link.addEventListener('click', swap_slide(slide), false);
        } else if (link.attachEvent) {
            link.attachEvent('onclick', swap_slide(slide));
        }
    }

    if (!element(location.hash.substr(1)))
        element('slajd-0').style.display = 'block';
    else 
        element(location.hash.substr(1)).style.display = 'block';
})();

everything works fine in Chrome, Opera, IE9, IE8, Safari, however in IE7 variable slide is null, IE7 reports the error in the function swap_slide, however the error might be somewhere else. I’m not sure if this is a scope error that I caused or is it simple IE retardation?

EDIT: The error IE spits out is:

Error: Unable to get value of the property ‘style’: object is null or undefined

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:21:21+00:00Added an answer on May 23, 2026 at 3:21 am

    Change

    getAttribute('href')
    

    to

    getAttribute('href',2)
    

    to get the href as defined and not as a expanded URL

    http://msdn.microsoft.com/en-us/library/ms536429%28v=vs.85%29.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is slightly off topic of programming but still has to do with my
I apologize if this is slightly off-topic. I'm hoping to find a software-as-a-service CRM
This is a sample (edited slightly, but you get the idea) of my XML
This is a compiler error (slightly changed for readability). This one always puzzled me.
This answer says that Linq is targeted at a slightly different group of developers
This question has been asked before ( link ) but I have slightly different
This question comes close to what I need, but my scenario is slightly different.
This is probably a simple question, and I'm slightly embarrassed to ask it, but
Sorry for the slightly rubbish title. I could not think how to describe this
This has some lengthy background before the actual question, however, it bears some explaining

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.