how to trigger a java script confirm box after the page loads completely
I need to reload a PHP scr开发者_StackOverflowipt on my page when I submit a form. When I submit, it has to load on the same page. When the form is submitted, I need to show the confirmation window to the user. However, the problem is that the confirm box is shown while the page is loading (and the page doesn't finish loading until the user selects an option).
------------<? if(){?>
<script>
if(confirm){
}else{
}
</script>
I need the confirm box to be triggered after the page loads completely. Any ideas as to why this might be happening?
Add it to the window.onload event:
window.onload = function () {
if (confirm...) {
...then...
} else {
...else...
}
}
or (what is better) use jquery:
$(function () {
if (confirm...) {
...then...
} else {
...else...
}
});
精彩评论