Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Ok, you are almost there:
1) function()
This create an anonymous function, it's usually used in asynchronous calls, to define directly what action should be done upon reception of datas.
In your case, you want a named function, declared by "function myName(){"
2) setTimeout
SetTimeout works by calling a defined action after a defined timeout. In that extent, you need to give a string to it, that it will call after the timeout. An anonymous function won't work here.
3) When you define named functions, you must call them, or make them called upon an event (click, load, mouseover...). In my code, I call it directly after defining the function.
4)Look out for syntax.
In the link_text variable, you have a <\/a> at the end. This is wrong and should be </a>. The slash won't interfere with other characters.
In that case, the script should rather be placed at the end of the page, and after the element to show.
Otherwise, on a slow pc, you could have the situation that the function try to set the innerHtml of an element that is still not loaded.
There is 1 implementation of what you want:
Code:
function countDown(){
var element_id = 'my_div' ; //name of div or object that you want the link to appear in (Div is best)
var link_text = '<a href="http://www.robertgarford.com/">Hello</a>'; //link code
var time = 3; //time in seconds until display
setTimeout('document.getElementById("'+element_id+'").innerHTML = '+link_text;},time*1000);
}
countDown();
__________________
Only a biker knows why a dog sticks his head out the window.
Last edited by tripy; 09-06-2007 at 01:33 PM..
|