I am implementing a popup with javascript which fire when the page is closed . I am using the unload() page handler. The problem is that the popup does not stays ... it popups for a while but then the new page loads.

I want it to stay there until user presses cancel..

Thanks

Recommended Answers

All 6 Replies

Give me some code please. I don't think it dissapeares like that. I implemented once something like that and it worked well for me. Some code should help me help you :).

you actually want your site blacklisted
you want to open a window to override user actions
Not a particularly good idea

actually it is not a window it is an iframe pop up.. like saying GoodBye to user...
Actually i am firing a function to show a MOOdle popup.
Here is the code.
I donot know whats wrong with it..

It starts to appear and then vanishes.

<html>
<head>
<title></title>

<script type="text/javascript" src="javascript/moodalbox121compressed/js/mootools.js"></script>
<script type="text/javascript" src="javascript/moodalbox.js"></script>
<script type="text/javascript" src="javascript/modalbox.js"></script>
<link href="javascript/moodalbox.css" rel="stylesheet" type="text/css" media="screen">
<script type="text/javascript">
window.onbeforeunload = popup;
function popup(){
MOOdalBox.open( "popup.htm","Some kind of caption", "450 305" )
}</script>

</head>
<body>

Well, it's all about how that moodle dialog works. I was talking about unload event on <body> and use of an alert() message. Try using window.stop() function from javascript (to stop the browser) and after you press OK or close the dialog use window.location.href="new_location" to redirect the browser. I can be wrong.. stop doesn't always work on all browsers... but I try to help somehow :).

the window.stop also does not works...
The popup loads but there is just a flash and then it vanishes...
I want it to load completely.

why an external file
could you use unload to change the visibility of a layer in the page's css without the extra time needed to download the file

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.