Doug Van
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:doRedirec t()">Conti nue 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.
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:doRedirec
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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></ce nter>";
document.body.appendChild( aLink);
}
</script>
</body>
</html>
==========================
<html>
<body bgcolor="white">
<script>
setTimeout("appendLink()",
function appendLink()
{
var aLink = document.createElement("a"
aLink.href = "http://www.google.com";
aLink.innerHTML = "<center><b>google</b></ce
document.body.appendChild(
}
</script>
</body>
</html>
ASKER
DOH! I think I need some sleep!
Thank you!
Thank you!
ASKER
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!