Click to See Complete Forum and Search --> : Advanced javascript


funkyfraisre
04-16-2007, 09:08 PM
Can someone please tell me how to create the effects you get at download.com when you mouse over a link. Is this javascript or something else, becasuse I am not able to fully understand the code in the view source.

Thank you in advance for your replies.

theRatWonder
04-17-2007, 05:55 AM
Yeah it will deffo be javascript.

<html>
<head>
<script type="text/javascript">
function displayBox(e) {
var myDiv = document.createElement('div');
myDiv.appendChild(document.createTextNode('bla bla bla bla bla bla de bla de de de hello world I am a fish etc')); // put whatever you like in the div
myDiv.style.position = "absolute";
myDiv.style.left = e.clientX;
myDiv.style.top = e.clientY;

var myTimeout = window.setTimeout(function () {document.body.appendChild(myDiv)},1000);

this.onmouseout = function() {
clearTimeout(myTimeout);
document.body.removeChild(myDiv);
}

return;
}
</script>
</head>
<body>
<span onmouseover="displayBox(event)">some text</span>
</body>
</html>


Something similar to that. Obviously that doesn't look half as flash.

Robin.

theRatWonder
04-17-2007, 05:56 AM
Moment of arrogance - I wrote that whole thing blind, and just tried it out and it worked perfectly :D (probably only in firefox tho).

ricp
04-17-2007, 06:04 AM
Moment of arrogance - I wrote that whole thing blind, and just tried it out and it worked perfectly :D (probably only in firefox tho).
Ooooh, hark at her!

Have a lolipop for being so good! :p

theRatWonder
04-17-2007, 06:09 AM
Alright, enough cheek out of you. I was impressed. That's all that matters.
:p