dodoecchi
05-14-2009, 04:02 PM
Hi,
I would like to prevent my link not to scroll back to the top right after I click the link to gray a div
here is a test file :
<html>
<head>
<style type="text/css">
p {
margin-bottom: 300px;
}
#dark {
width: 1px;
height: 1px;
opacity:.50;
background-color: black;
z-index:10;
display : none;
position: absolute;
}
</style>
<script type="text/javascript">
function BlackOut(targetDiv, theDarker) {
document.getElementById(theDarker).style.display = "block";
document.getElementById(theDarker).style.height = document.getElementById(targetDiv).offsetHeight+'px';
document.getElementById(theDarker).style.width = document.getElementById(targetDiv).offsetWidth+'px';
document.getElementById(theDarker).style.top = document.getElementById(targetDiv).offsetTop+'px';
document.getElementById(theDarker).style.left = document.getElementById(targetDiv).offsetLeft+'px';
}
</script>
</head>
<body>
<h1>This is my test page</h1>
<p>Paragraph, let's skip some text</p>
<p>Once more</p>
<div id="dark"></div>
<div id="mydiv">my div <a href="#" onClick="BlackOut('mydiv', 'dark')">click to darken</a></div>
<p>.</p>
</body>
</html>
any suggestions?
Dorian -from France
I would like to prevent my link not to scroll back to the top right after I click the link to gray a div
here is a test file :
<html>
<head>
<style type="text/css">
p {
margin-bottom: 300px;
}
#dark {
width: 1px;
height: 1px;
opacity:.50;
background-color: black;
z-index:10;
display : none;
position: absolute;
}
</style>
<script type="text/javascript">
function BlackOut(targetDiv, theDarker) {
document.getElementById(theDarker).style.display = "block";
document.getElementById(theDarker).style.height = document.getElementById(targetDiv).offsetHeight+'px';
document.getElementById(theDarker).style.width = document.getElementById(targetDiv).offsetWidth+'px';
document.getElementById(theDarker).style.top = document.getElementById(targetDiv).offsetTop+'px';
document.getElementById(theDarker).style.left = document.getElementById(targetDiv).offsetLeft+'px';
}
</script>
</head>
<body>
<h1>This is my test page</h1>
<p>Paragraph, let's skip some text</p>
<p>Once more</p>
<div id="dark"></div>
<div id="mydiv">my div <a href="#" onClick="BlackOut('mydiv', 'dark')">click to darken</a></div>
<p>.</p>
</body>
</html>
any suggestions?
Dorian -from France