Javascript Noob

DylanS

Well-Known Member
Joined
May 10, 2010
Messages
280
Reaction score
0
Location
Durban
I have never used javascript before and I hit a dead end...
I need a function that I can execute at <body onload=.....> that will mouse over a link with the ID="d1"
Please help if you can Like I said I am a NOOB

It is an Html page with java btw...
Thanks :)
 
It's Friday and I'm feeling generous, so...

^^ What he said.

Code:
<html>
<body>
<a href="..." id="d1">Link</a>
<script type="text/javascript">
function setup() {
var link=document.getElementById('d1');
link.onmouseover = function() { 
  //do something
};
}
window.onload = setup;
</script>
</body>
</html>

Of course, there is also the jQuery library if you are going to get a little more serious (as a noob should :)) - that would look something like this:
Code:
<html>
<body>
<a href="..." id="d1">Link</a>
<script type="text/javascript">
$(function(){
  $('#d1').mouseover(function() {
    //do something
  });
};
</script>
</body>
</html>

Of course, I'm simplifying things somewhat, but you should get the jist of it.
 
Code:
<a href="whatever" onmouseover="foo()">mylink</href>
<script>
	function foo() {
		//dostuff
	}
  </script>
 
Last edited:
Hmm, you can maybe try moving the link to the cursor after getting its x and y positions. That is all I can think of.
 
you can maybe try moving the link to the cursor

ROFL :D

Sorry, was just visualising a hyperlink following the mouse cursor around the screen!!! What would happen if the cursor was over the taskbar?

But to the OP: don't think you can move the mouse cursor with Javascript. Browser script doesn't have such low-level system access.
 
Top
Sign up to the MyBroadband newsletter
X