• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 146
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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