/    Sign up×
Community /Pin to ProfileBookmark

Replacing Document.all

I have used a script to open a drop down link in a window from another hyperlink.

I use the hyperlink:

topic_title.htm#2

to open the third drop-down hotspot on topic topic_title.htm.

In the topic with the drop-down hotspot, I use the following script:

<!–(Scripts)=======================================================–>

<script language=JavaScript><!–
/*
*
/
function getQueryNumber() {
query = ‘ ‘ + this.location;
// Get the current URL so we can parse out the data.
queryIndex = query.indexOf(‘#’)
if (queryIndex == -1) {
value = -1
}else{
value = query.substring(queryIndex + 1);
// Keep everything after the pound sign ‘#’.
}
return value;
}

function expandLinkedItem() {
var arrayofDivs = document.all.tags(“DIV”);
expandDiv = getQueryNumber();
if (expandDiv != -1){
arrayofDivs[expandDiv].style.display = “block”;
}
}
// –></script>

</head>

<!–(Body)==========================================================–>

<body onLoad=”setTimeout(‘expandLinkedItem();’,50)”>


——————————————————

However, I found that this recently stopped working in Netscape, Mozilla, and FireFox.

In FireFox I got two error messages:

  • 1. On one line, it said to “Warning: Non-standard document.all property as used. Use W3C standard document.getElementById() instead. If you search the script above for “document.all” you will find this line only once.
  • I tried simply replacing “document.all” with “document.getElementById”, but that did not work. Instead I got the message “Error: document.getElementById.tags is not a function”

  • 2. The second error I got for three lines down. It says, “arrayofDivs has no properties.
  • Any ideas how I adjust this script to work with FireFox, etc?

    Thanks!!
    Troy

    to post a comment
    JavaScript

    3 Comments(s)

    Copy linkTweet thisAlerts:
    @nzakasMay 05.2005 — You actually need to replace document.all.tags("DIV") with this:

    document.body.getElementsByTagName("div")
    Copy linkTweet thisAlerts:
    @UltimaterMay 05.2005 — Why not: [color=royalblue]document.getElementsByTagName("div")[/color] ?
    Copy linkTweet thisAlerts:
    @Troy_WellsauthorMay 05.2005 — document.body.getElementsByTagName works. How easy is that!!

    Thanks!!

    Troy
    ×

    Success!

    Help @Troy_Wells spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.1,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,
    )...