/    Sign up×
Community /Pin to ProfileBookmark

Delaying show of layer

Hi,

I need to delay when layer becomes visible, how do I accomplish this?

thanks,
Alex

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisApr 04.2003 — Use setTimeout():setTimeout("layerobj.style.visibilty='visible'", 1000); // 1000 = one second
Copy linkTweet thisAlerts:
@khalidali63Apr 04.2003 — function showLayer(){

layer.style.visibility="visible";

}

and where ever you want this to be called say from a link may be

<a href="javascript:setTimeout('showLayer()',3000)">Show Layer</a>

This will show the layer with 3 secs delay.

Cheers

Khalid
Copy linkTweet thisAlerts:
@webtekieauthorApr 04.2003 — wow, that was fast reply. Thanks guys.

Well, I tried it, but it does not work. Here is what I have:

external file:
--------------


isNS4 = (document.layers) ? true : false;

isIE4 = (document.all && !document.getElementById) ? true : false;

isIE5 = (document.all && document.getElementById) ? true : false;

isNS6 = (!document.all && document.getElementById) ? true : false;

function switchDiv(strDivName,bolVisible){

//identify the element based on browser type

if(isNS4) {

objElement = document.layers[strDivName];

} else if (isIE4) {

objElement = document.all[strDivName];

} else if (isIE5 || isNS6) {

objElement = document.getElementById(strDivName);

}

if(isNS4){

if(!bolVisible) {

objElement.visibility ="hidden"

}else{

objElement.visibility ="visible"

}

}else{

if(!bolVisible) {

objElement.style.visibility = "hidden";

}else{

objElement.style.visibility = "visible";

}

}

}

in HTML page:
----------------


<SCRIPT LANGUAGE="JavaScript1.2" SRC="DelayTicker.js" TYPE='text/javascript'></SCRIPT>

<body onLoad="javascript:setTimeout('switchDiv('myDiv',true)',10000)">

<div id="myDiv" style="visibility:hidden;position:relative">

Test layer

</div>

What am I doing wrong here?

thanks,

webtekie
Copy linkTweet thisAlerts:
@khalidali63Apr 04.2003 — try this line...

<body onLoad="setTimeout('switchDiv('myDiv',true)',10000)">

Cheers

Khalid
Copy linkTweet thisAlerts:
@webtekieauthorApr 04.2003 — Great! Thanks Khalid it works now...
×

Success!

Help @webtekie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...