/    Sign up×
Community /Pin to ProfileBookmark

Almost but not quite!

Could someone please look at the code below and explain why some bits work but other don’t.

It seems point to the file.

In all the well behaved browsers it makes the layer visible and then hides it again. In IE6 it shows the layer but then brings up all the files in the folder from which the page is run.

Code:-

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>

<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta name=”generator”
<meta http-equiv=”content-type”
content=”text/html; charset=ISO-8859-1″ />

<title>show/hide div</title>

<style type=”text/css”>

body {
font-size: 100%;
}

p {
font-size: 1em;
}

h1, h2 {
text-align: center;
}

</style>

<script language=”JavaScript”>
<!–

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//–>
</script>

<script type=”text/javascript”>

function change(which) {
document.getElementById(‘div1’).style.display = ‘none’;
document.getElementById(‘div2’).style.display = ‘none’;
document.getElementById(‘div3’).style.display = ‘none’;
document.getElementById(which).style.display = ‘block’;
}

function cleardiv() {
document.getElementById(‘div1’).style.display = ‘none’;
document.getElementById(‘div2’).style.display = ‘none’;
document.getElementById(‘div3’).style.display = ‘none’;
}

</script>
</head>

<body>
<h1>Switch Divs</h1>

<p>Click on a button, new layer appears. </p>
<p>MouseOver Link #1, new layer appears. </p>
<p>MouseDown Link #2 or OnClick Link #3, new layer appears and then jumps to Folders. </p>
<p>
<input name=”Button” type=”button” onclick=change(“div1″) value=”Layer 1” />
<input name=”Button” type=”button” onclick=change(“div2″) value=”Layer 2” />
<input name=”Button” type=”button” onclick=change(“div3″) value=”Layer 3” />
</p>

<p>Select Layer:
<a href=”” onMouseover=”change(‘div1’);”>Layer 1</a> |
<a href=”” onMousedown=”change(‘div2’);”>Layer 2</a> |
<a href=”” onmousedown=”change(‘div3’)”>Layer 3</a>
</p>

<div id=”div1″ style=”display: none; background-color:#30F;”>
<h2>Division 1</h2>
</div>

<div id=”div2″ style=”display: none; background: #8f8;”>
<h2>Division 2</h2>
</div>

<div id=”div3″ style=”display: none; background: #f88;”>
<h2>Division 3</h2>
</div>

</body>

<script language=”JavaScript”>
<!–

window.open = SymRealWinOpen;

</script>

</html>

to post a comment
HTML

3 Comments(s)

Copy linkTweet thisAlerts:
@PittimannJan 18.2005 — Hi!

Simply use this:

<a href="#" onMouseover="change('div1');return false;">Layer 1</a> |

<a href="#" onMousedown="change('div2');return false;">Layer 2</a> |

<a href="#" onmousedown="change('div3');return false;">Layer 3</a>

for your links.

Cheers - Pit
Copy linkTweet thisAlerts:
@phpnoviceJan 18.2005 — ...or, since you're using a lot of JavaScript that might break your page anyway (for certain visitors), use this:

<a href="javascript:void(0);" onMouseover="change('div1');return false;">Layer 1</a> |

<a href="javascript:void(0);" onMousedown="change('div2');return false;">Layer 2</a> |

<a href="javascript:void(0);" onmousedown="change('div3');return false;">Layer 3</a>

The reason is that using the '#' may cause other erroneous results when no bookmark is to be found.
Copy linkTweet thisAlerts:
@MimorkerisauthorJan 18.2005 — Thanks Pit, I remember seeing something about page flashing a few days ago and this was the cure, I think!

Just tested it works fine in NN, FireF, IE6 but Opera is now flashing, cant seem to get rid of link to file, even if I close it down and restart. Have I broken Opers, do you think?
×

Success!

Help @Mimorkeris 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.6,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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