/    Sign up×
Community /Pin to ProfileBookmark

setting timeout

Hi

where in this script could I set a timeout to remove the popup? I have a document.onclick = hideCurrentPopup; but it only works if you click somewhere in the document, I would like it to disappear after 15 seconds if the user is not going to enter anything.

thanks

function showPopup (targetObjectId, eventObj) {
if(eventObj) {
// hide any currently-visible popups
hideCurrentPopup();
// stop event from bubbling up any farther
eventObj.cancelBubble = true;
// move popup div to current cursor position
// (add scrollTop to account for scrolling for IE)
moveObject(targetObjectId, 0, 45);
// and make it visible
if( changeObjectVisibility(targetObjectId, ‘visible’) ) {
// if we successfully showed the popup
// store its Id on a globally-accessible object
window.currentlyVisiblePopup = targetObjectId;
return true;
} else {
// we couldn’t show the popup, boo hoo!
return false;
}

} else {
// there was no event object, so we won’t be able to position anything, so give up
return false;
}

} // showPopup

function hideCurrentPopup() {
// note: we’ve stored the currently-visible popup on the global object window.currentlyVisiblePopup
if(window.currentlyVisiblePopup) {
changeObjectVisibility(window.currentlyVisiblePopup, ‘hidden’);
window.currentlyVisiblePopup = false;
}
} // hideCurrentPopup

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @jenn2 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...