...

View Full Version : transparent and onclick



josip208
11-21-2010, 03:41 PM
I need a code that makes the following:

1. I need a link to a certain website
2. If someone click that link it opens in new tab and it makes 1. link invisible and show a another link on the same place with a time delay of 5 seconds

Philip M
11-21-2010, 04:45 PM
You can't tell a browser to open in a new tab, just a new window (which it's up to the browser to interpret as a new tab). Opening in a new tab is behaviour which is configured by the user and, as far as I know, only by the user. This is the best you can do.


<div id = "mydiv1" style="display:block">
<a href="http://www.google.com" target="_blank" onclick = "hideFirst()">First Link Text</a>
</div>

<div id = "mydiv2" style="display:none">
<a href="http://www.javascriptkit.com" target="_blank">Second Link Text</a>
</div>

<script type = "text/javascript">
function hideFirst() {
document.getElementById("mydiv1").style.display="none";
setTimeout("showSecond()",5000);
}

function showSecond() {
document.getElementById("mydiv2").style.display="block";
}
</script>

"Insanity is doing the same thing over and over again, but expecting different results." - Rita Mae Brown



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum