This question already has answers here:
jquery/javascript alert popup on a set time
(2 answers)
Closed 5 years ago.
i have a bootstrap modal popup with following code that runs every time page loads.
I need the script run once for each session with cookie and cookie will expire after 5 minutes. can you please help?
here's the code:
$(window).on('load',function(){
$('#myModal').modal('show');
});
setInterval(showModal, 300000);
function showModal()
{
$('#myModal').modal('show');
}
Related
This question already has answers here:
How to reload page every 5 seconds?
(11 answers)
Closed 2 years ago.
This only refreshes the page once, I have tested it. How do I make it reload the page every 5 seconds and look for an element then click on it?
function reload() {
document.location.reload();
}
setTimeout(reload, 5000);
Hopefully this is what you're looking for.
setTimeout(() => {
const button = document.querySelector('.button');
button.dispatchEvent(new MouseEvent('click'));
window.location.reload();
}, 5000)
This question already has answers here:
How can I override the OnBeforeUnload dialog and replace it with my own?
(12 answers)
Is it possible to display a custom message in the beforeunload popup?
(7 answers)
javascript onbeforeunload not showing custom message
(1 answer)
Closed 3 years ago.
I have this code :
$(window).bind("beforeunload", function() {
App.confirm('popup.cancel.confirmation.message', $('#confirm-import-modal'), true);
return "Do you really want to close?";
});
I have 2 questions about this piece of code :
I have always the message This page is asking you to confirm that you want to leave - data you have entered may not be saved., and I put the message Do you really want to close?
App.confirm show a popup, is possible to display only this popup whitout the confirm default popup from javascript ? Because now I have 2 popups, one default from javascript and another generate by App.confirm()
Thanks in advance.
This question already has answers here:
I want to delay a link for a period of 500 with javascript
(5 answers)
Closed 6 years ago.
Is it possible to delay a hyperlink by 3 seconds as CSS has the delay animation, I have some icons with animation on them, for a mobile user they cant hover over the icons, but they would be able to see the icon animation if i had a delay on the hyperlinks?
Is this possible?
Thanks All!
Related post: I want to delay a link for a period of 500 with javascript
In summary:
HTML:
Javascript:
function delay (URL, ms) {
setTimeout( function() { window.location = URL }, ms);
}
This question already has answers here:
How to schedule IE page reload
(4 answers)
Closed 8 years ago.
here's my problem: i need to display a message for a while, and then reload the page.
can someone tell me how to reload a page, after certain delay?
You don't even need jQuery or HTML5 for this:
setTimeout(location.reload.bind(location), 60000);
This will wait 1 minute (60,000 milliseconds), then call the location.reload function, which is a built-in function to refresh the page.
setTimeout(function(){
window.location.reload(); // you can pass true to reload function to ignore the client cache and reload from the server
},delayTime); //delayTime should be written in milliseconds e.g. 1000 which equals 1 second
Update:
One-liner using ES6:
setTimeout(() => window.location.reload(), delayTime);
You may try this without js, it cycles:
<meta http-equiv="refresh" content="5"/> <!-- 5 sec interval-->
<h1>Page refersh in every 5 seconds...</h1>
You can even navigate to a different page, visiting google home page
<meta http-equiv="refresh" content="5;http://www.google.com"/> <!-- 5 sec delay-->
<h1>Redirecting in 5 seconds...</h1>
This question already has answers here:
JavaScript alert box with timer
(11 answers)
Closed 9 years ago.
For my website I would like an alert box message to appear 4 seconds after the page is opened. I cant figure out how to do this as the timed function works if a button is clicked but I would like the alert box to pop up automatically withoutt any user input/button and then shut when the user clicks "okay"...
Any ideas or posts related to this topic would be great help!
Thanks
<script type = "text/javascript">
window.onload=function(){setTimeout(showPopup,4000)};
function showPopup()
{
//write functionality for the code here
}
</script>
In it's most simple form:
setTimeout(function(){alert("Hello")},4000);
4000 = 4 seconds
If you want an alert to appear after a certain about time use this code:
setTimeout(function() { alert("Your Message"); }, time);