/    Sign up×
Community /Pin to ProfileBookmark

IE onclick problem, works with FF

Hi, I have a few javascript functions which work perfectly well in Firefox, but do nothing in IE.

Since they DO work in FF, there must be some very small tweaking that needs to be done to make this understandable for IE..

I didnt include the CSS

Javascript:

[CODE]
<script type=”text/javascript”>
<!–
var state = ‘hidden’;

function showhide(layer_ref) {
if (state == ‘visible’) {
state = ‘hidden’;
}
else {
state = ‘visible’;
}
if (document.all) {
eval( “document.all.” + layer_ref + “.style.visibility = state”);
}
if (document.layers) {
document.layers[layer_ref].visibility = state;
}
if (document.getElementById && !document.all) {
maxwell_smart = document.getElementById(layer_ref);
maxwell_smart.style.visibility = state;
}
}
function hide(layer_ref) {
if (state == ‘visible’) {
state = ‘hidden’;
}
if (document.all) {
eval( “document.all.” + layer_ref + “.style.visibility = state”);
}
if (document.layers) {
document.layers[layer_ref].visibility = state;
}
if (document.getElementById && !document.all) {
maxwell_smart = document.getElementById(layer_ref);
maxwell_smart.style.visibility = state;
}
}

//–>
</script>
[/CODE]

and here is the HTML

[code=html]
<div class=”ivo2″>

<div class=”ivo2-nav”>
<a href=”#” onclick=”showhide(‘ivo2-block1’);document.getElementById(‘ivo2-nav-link1′).style.background=’#FFA766’;document.getElementById(‘ivo2-nav-link2′).style.background=’#FFD69D’;hide(‘ivo2-block2’);return false” id=”ivo2-nav-link1″>Most Active</a>
</div>

<div class=”ivo2-nav”>
<a href=”#” onclick=”showhide(‘ivo2-block2’);document.getElementById(‘ivo2-nav-link1′).style.background=’#FFD69D’;document.getElementById(‘ivo2-nav-link2′).style.background=’#FFA766’;hide(‘ivo2-block1’);return false” id=”ivo2-nav-link2″>New</a>
</div>

<div id=”ivo2-block1″>foo</div>
<div id=”ivo2-block2″>bar</div>

</div>

[/code]

Has anybody else come across a problem like this?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@kangoauthorSep 18.2009 — It gives a Syntax error for the following line:

[CODE]
eval( "document.all." + layer_ref + ".style.visibility = state");
[/CODE]
Copy linkTweet thisAlerts:
@kangoauthorSep 18.2009 — Ok i removed this "eval" function and now the tabs work, there is no more error, but there still remains the hide function which doesn't seem to be working yet in IE
Copy linkTweet thisAlerts:
@kangoauthorSep 18.2009 — anybody got any ideas?
Copy linkTweet thisAlerts:
@kangoauthorSep 20.2009 — need to bump this thread
×

Success!

Help @kango 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.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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