Forum Moderators: open

Message Too Old, No Replies

On three clicks open window in a different frame...

This is to add a little fun for my site!

         

JAB Creations

4:06 am on Jan 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I want to have a window open in a frame called "border" after a person clicks three times. I'm not sure how to have JS count and then do something when it reachs a certain variable though.

adni18

1:23 pm on Jan 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



At the top of the document, define the variable:

<script language="javascript">
<!--
var clickCount=0;
//-->
</script>

then, in the object you want to count the clicks upon,

<BODY onClick="clickCount++;if(clickCount==3){alert('Third click registered.')}">

orion_rus

1:28 pm on Jan 11, 2005 (gmt 0)

10+ Year Member



In object where user needs to make 3 clicks u should add a function onclick="freeclicks()".
In a head of document u need to add

<script>var clicktimes;
function freeclicks()
{clicktimes++;
if (clicktimes==3) {window.open(parameters);clicktimes=0;
}
</script>

Good luck to you

adni18

12:57 pm on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



var clicktimes;

The only problem with this, is that when it is increased, some browsers will pick clicktimes up as "null".

var clicktimes=0;

is the better option.