Link to home
Start Free TrialLog in
Avatar of Doug Van
Doug VanFlag for Canada

asked on

Creating a delayed link display in Javascript

Hello folks,

I searched the Internet and have had no luck finding a Javascript that will allow me to delay the display of a link.

There are plenty of great delayed links, such as this one:

<head>
<script language="JavaScript">
<!--
var sTargetURL = "http://www.target page.com/index.html";

function doRedirect()
{ setTimeout( "timedRedirect()", 40*1000 ); }

// There are two definitions of 'timedRedirect', this
// one adds to the visitors page history.
function timedRedirect()
{
window.location.href = sTargetURL;
}
//-->
</script>
<script language="JavaScript1.1">
<!--
function timedRedirect()
{ window.location.replace( sTargetURL ); }
//-->
</script>
</head>

<body>
  <p align="center" class="style2">
<a href="javascript:doRedirect()">Continue to Website</a>

But I am not interested on a delay after the link is displayed. Rather, I want to delay the *displaying* of the text, "Continue to Website."

There are two possible ways to do this...
1 - make the text (link) appear invisable (same as background color) and change it to a different color after a preset amount of time
OR
2 - actually hold back the display of the text (link) until a preset amount of time has past.

I will offer an additional 125 pts for both methods.

How can I accomplish this task?

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of devic
devic
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Doug Van

ASKER

Fantastic!

This is exactly what I am looking for!

Can you please tell me how to get the "aLink.innerHTML = "<b>google</b>";"  to center on the webpage (rather than default to left justified).

Thank you again!
simple add <center> tag:
=======================================
<html>
<body bgcolor="white">

<script>
setTimeout("appendLink()", 2000);


function appendLink()
{
     var aLink = document.createElement("a");
     aLink.href = "http://www.google.com";
     aLink.innerHTML = "<center><b>google</b></center>";
     document.body.appendChild(aLink);
}
</script>


</body>
</html>
DOH! I think I need some sleep!

Thank you!