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);
Related
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:
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');
}
This question already has answers here:
How to Detect "prevent this page from creating additional dialogs"
(2 answers)
Closed 7 years ago.
I want to show a alert like this
while(1){alert("safdf");}
when the user hits dont show this alert again. I want to redirect the user to the url ="xyz.com". like this.
<script type="text/javascript">
function ialerts_crash()
{
while(1){alert("safdf");}
window.location.href = 'example.com';
if(what to put here to exit when user hits dont show this alert again){return ;}
}
ialerts_crash();
</script>
I wonder how to break; the while loop when the user hits 'dont show this alert again'.
when the user hits dont show this alert again.
"dont show this alert again" is not a feedback option that a script can read back. It's merely a browser feature that allows the user to kill annoying alerts.
So what you actually want is to use window.confirm. It returns a boolean value, which you can use in the break condition of your loop.
var msg = "You will be redirected. There's ";
while (!confirm(msg + "no way out."))
msg += "really ";
location.href = 'example.com';
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do I disable right click on my web page?
I want to disable right click and Ctrl+V & Ctrl+C keypresses on a web page using JavaScript. I have a page where customers has to enter the enquiry details. I don't want them to copy some data and paste it in some fields. Anyone, please help me.
Try this:
Check this link Disabling-the-right-click-on-web-page
<script language="javascript">
document.onmousedown=disableclick;
status="Right Click Disabled";
Function disableclick(e)
{
if(event.button==2)
{
alert(status);
return false;
}
}
</script>
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Is there a way to catch the back button event in javascript?
In my application,the user can enter data eithe add or modify those modification is saved into database using ajax.After all the modifications is completed in the screen then user will be finalized the data.In the time,user accediently click on Browser 'Back' Button.
So,what i need is,if user clicked without 'Update' button then if clicks the Browser 'Back' button.i want to shown the alert message.So,How to detect/capture the 'Back' Button.Please help me
You could use the window.onbeforeunload event
<body onunload="Unloader()">
<script type="text/javascript">
function Unloader() {
}
</script>