Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.