View Full Version : transparent and onclick

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 id = "mydiv2" style="display:none">
<a href="http://www.javascriptkit.com" target="_blank">Second Link Text</a>

<script type = "text/javascript">
function hideFirst() {

function showSecond() {

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