...

View Full Version : Resolved Counting Links



SpongeRob
03-03-2012, 11:13 PM
<!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 http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test Project</title>

<script type="text/javascript">
var clicks=0;
function linkClick(){
document.getElementById('clicked').value = ++clicks;
}
</script>

</head>

<body>

<p align="center"><a href="http://www.google.ie" target="_blank" onclick="linkClick()">Google</a></p>
<p align="center">&nbsp;</p>
<p align="center"><a href="http://www.google.ie" target="_blank" onclick="linkClick()">Google</a></p>
<p align="center">&nbsp;</p>
<p align="center"><a href="http://www.google.ie" target="_blank" onclick="linkClick()">Google</a></p>
<p align="center">&nbsp;</p>

<td colspan="3" valign="top">You have clicked my links <input id="clicked" size="1" onfocus="this.blur();" value="0" > times</td>
<Script Language="JavaScript">
if ("clicks">3);
{
window.open('http://ie.yahoo.com','','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no ,status=no');
}
</Script>

</body>

</html>

I am a complete novice, I've spend most of today trying to research and learn Javascript.

I would like my page to keep a count of how many times the links have been opened (this is happening)

I would like a new pop up window to occur when the count gets to a specif value (this isnt happening) OR maybe to have a new hyperlink to appear that the user can then click on?

Thanks in advance.

felgall
03-03-2012, 11:59 PM
Browsers block popup windows unless they are directly triggered by someone clicking a link.

If the browser is going to allow it then the following should work:


<script type="text/javascript">
var clicks=0;
function linkClick(){
document.getElementById('clicked').value = ++clicks;
if (clicks>3) {
window.open('http://ie.yahoo.com','','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no ,status=no');
}
}
</script>

SpongeRob
03-04-2012, 12:32 PM
Felgall, thank-you for that, working perfectly :-)

Appreciate your assistance :-)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum