• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 140
  • Last Modified:

one function after another

I want the onmouseover function in action only after the body is clicked on once. How do I do this?
<script type="text/javascript">

var timer_is_on=0;


function show_coords(event)
{
var x=event.clientX;
var y=event.clientY;
document.getElementById("oo").innerHTML= x+" "+y;
}


function doTimer ()
{
	if(!timer_is_on){ timer_is_on=1; show_coords(event);  }
	
	return true;
	
}





</script>

</head>



<body onmousedown="show_coords(event)" onmouseover="return doTimer()">

<p>Click in the document. An alert box will alert the x and y coordinates of the mouse pointer.</p>

<p id="oo"></p>

Open in new window

0
charmingduck
Asked:
charmingduck
  • 2
1 Solution
 
mwochnickCommented:
try this
<html>
<head>
<script type="text/javascript">

var timer_is_on=0;

function flip_hover() {
	if (timer_is_on)
		timer_is_on = 0;
	else
		timer_is_on = 1;
}


function show_coords(event)
{
var x=event.clientX;
var y=event.clientY;
document.getElementById("oo").innerHTML= x+" "+y;
}


function doTimer (event)
{
        if(!timer_is_on){
			show_coords(event);
		}
        return true;
}
</script>

</head>

<body onclick="flip_hover()" onmouseover="return doTimer(event)">
<p>Click in the document. An alert box will alert the x and y coordinates of the mouse pointer.</p>
<p id="oo"></p>
</body>
</html>

Open in new window

0
 
mwochnickCommented:
a couple of things clicking turns it on and off
one correction the hover is on to start with in the code above - need to change line 25 to this to reverse
        if(timer_is_on){
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now