Jump to content

A countdown or timing event system


kamal213

Recommended Posts

Hi guys,

 

I am looking for a <script> which will display a link after 5secs/5day/5months. I got a script of the w3c tutorial see below.

 

<html>

<head>

<script type="text/javascript">

function timeMsg()

{

var t=setTimeout("alertMsg()",3000);

}

function alertMsg()

{

alert("Hello");

}

</script>

</head>

 

<body>

<form>

<input type="button" value="Display alert box in 3 seconds" onClick="timeMsg()" />

</form>

</body>

 

</html>

 

The issue is that just displayes an alert box - I would prefer a link to be displayed instead.

 

Please guys your ideas, scripts or suggestion are more than welcome.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/236107-a-countdown-or-timing-event-system/
Share on other sites

<html>
<head>
<script type="text/javascript">
function timeMsg()
{
var t=setTimeout("alertMsg()",3000);
}
function alertMsg()
{
var elem = document.getElementById("link");
elem.innerHTML = "<a href=\"#\">Link</a>";
}
</script>
</head>

<body>
<form>
<input type="button" value="Display alert box in 3 seconds" onClick="timeMsg()" />
</form>

<p id="link">A link will appear here!</p>
</body>

</html>

 

That should help you make it do what you want it to do. You can change the # in "<a href=\"#\">Link</a>" to whatever link you want it to be.

Optionally you can use another element like <span> if you want the link to appear somewhere else or in a block of text.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.