/    Sign up×
Community /Pin to ProfileBookmark

Simple script doesn’t work in IE?

I’m pretty new to JS but I think I’m picking it up not too bad. This problem has perplexed me though. I’m trying to use Prototype and Scriptaculous:

[CODE]var gameInfo = Class.create();

gameInfo.prototype = {

initialize: function() {
if (!document.getElementsByTagName){ return; }
var anchors = document.getElementsByTagName(‘a’);

// loop through all anchor tags
for (var i=0; i<anchors.length; i++){
var anchor = anchors[i];

if (anchor.getAttribute(‘href’) && anchor.getAttribute(‘class’) == ‘gameTitle’){
anchor.onclick = function () {myGameInfo.start(); return false;}
}
}
},
start: function() {
new Effect.toggle(‘gameInfo’, ‘slide’);
}

}

function initGameInfo() { myGameInfo = new gameInfo(); }
Event.observe(window, ‘load’, initGameInfo, false);[/CODE]

I’ll admit, I’ve based a lot of this code on Lightbox2.0 but it does something much simpler.

If you go to [URL=http://psf.gamehideout.co.uk/dah.php]this (work-in-progress) page[/URL] and click on “Destroy all Humans!” you’ll see what I’m trying to acheive. Of course, you need to use Firefox or Opera (hopefully Safari as well. Can anyone confirm?) as it doesn’t work in IE.

I know I could get that effect without the above code but I needed it to degrade gracefully. This way people without JS can view the same content but on another page (doesn’t work yet as the site is very incomplete).

If anyone can shed light on why this doesn’t work in IE I’d be very grateful ?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@spl1nterauthorSep 08.2006 — OK, so I fixed it by changing one of the lines to:
if (anchor.getAttribute('href') &amp;&amp; anchor.className == 'gameTitle'){but I now have a different problem...

It crashes IE! Can anyone else check if that happens with them? Go to the page linked in the first post and click "Destroy all Humans!".
Copy linkTweet thisAlerts:
@spl1nterauthorSep 08.2006 — Actually, it has nothing to do with this script.

Seems to be a problem with the slide animation in Scriptaculous. It works perfect when using blind instead.
×

Success!

Help @spl1nter 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 5.8,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...