Onload Without Onunload Being Executed...
Jul 20, 2005I would like to ignore onUnload action when the user reloads the page!!
View 6 RepliesI would like to ignore onUnload action when the user reloads the page!!
View 6 RepliesI have some code that gets executed in a document onload event.
I display an alert message box saying that some action was performed successfully.
However the following annoying issue is bothering me.
Whenever someone bookmarks the page, or go back to it, or even refreshes it, then the onload event gets fired again and the alert box appears.
Is there a safe way to make sure that the code in onload will get executed only once? and that cosecutive triggering of the page will not trigger any code execution.
The most important thing to note, is that I pass a parameter in the URL indicating that the code should be triggered in the onload event.
Obviously when I refresh the screen, the parameter is passed again and the code gets executed..
I'm trying to implement an exit pop up message when a visitor leaves the site. I'm using the "onunload" event handler. In FF, it works fine. The message appears. But in IE, the pop up only appears when I do a hard (shift+refresh) refresh.
Any ideas why IE is acting differently?
I am trying to use the onunload event to know when the user closes a
popup by receiving a request on the web server.
I have a main page from where the user opens a popup. What I want is
when the user closes the popup, it sends a request to my web server
(GoAhead) using the onunload event, then closes the popup.
For the moment, this what i have: when the user closes the popup, I
use the onunload event to open a different popup (by this way, I get a
request on the web server and I know that the user closes the first
popup), then, this new popup closes itself with the onload event. It
is working but having this second popup opening and closing is not
very neat.
If I try to change the location of the first popup in the onunload
event: onunload="document.location='....'", it doesn't send a request
to the web server when the user closes the popup.
Is there a way to send a request to the webserver when the user closes
the popup without the need to have an extra popup opened and closed ?
The web server I am using is working on a pseudo "cgi" mode called
"goforms", it avoids to create a different process for each request.
With "goforms", each request is handled by a unique process which is
always running.
I have an onunload event in the body tag. When it is activated I want to
know if a <a></a> href was clicked and which one. Is there some document
property or any other object available for such a thing?
Is there anyway to display a confirm msg onUnload of a page?
I mean to say if iam calling onUnload=javascript:check();
and in check(){
if(confirm("check?"))
{
unload the page;
}
else
{
Dont unload , just come back to the previous state( i have some
values in text fields to be retained)
}
}
I want to call this function on Unload.
I'm using IE6 and I've just created a simple page with this event:
<body onunload="alert('sad')">
could someone tell me if this works for you if you have IE 6? I've
tested this in firefox and IE 7 and they both work fine with it. but on
the IE6 copy I'm testing, the event is fired only when the page is
refreshed. It's not fired when I close the page...
I was trying to combine PHP & JavaScript to acheive on task:
I was trying to use javascript function to perform an PHP code, but the onUnLoad function seems to perform that query when the visitors reloads the page?
I want the PHP code to execute when the user EXITS the page.
javacript code....
<body onunLoad="doExit();">
Can anyone give me a function name or how can I make that work with onUnLoad?
I'm working on an asp.net site and am trying to implement a popup help
window. I want the window to close when the user advances to the next page
in our application. The thing is, I'm doing this on a component basis and I
don't have access to the body tag from within my help component, so I can't
add the onunload tag. Is there some other way of achieving what I want? Can
I add an eventhandler to the body tag through javascript?
does anyone have sample code to display a pop up when a user leaves the
site? I really don't want to use this technique, but the clients
demand it.
I'm thinking something like un body onunload, catch the URL they're
linking to and parse it for our own site's url and only display the pop
up if they're different.
Is there a way to detect if the reason an onUnload()
handler was called originated from the user explicitly
refreshed the page(s)?
Ie. pressed "Ctrl-R", "F5" or klicked the refresh button
in the toolbar or the context menu?
I'm aware that I can not stop a refresh, but the reason
I want to know is that I have a hidden frame in an intranet
application. This hidden frame is present at all times after
the user have sucessfully logged in (to our db).
So the only time this frame is closed is when the user
navigates away from the intranet app. At which point I want
to log him/her out.
I do thid With an AJAX call in the unload-event of the hidden
frame.
*BUT*... This leads to logging out if the user presses "F5",
or in other ways refresh the window, since a refresh reloads
both frames.
So I thought that if I could detect that this was a refresh in
progress, I can avoid logging him/her out.
To make my system's admin page safer maybe I should apply
<body onunload=""> somehow so that admin session would be reseted
immediately after user closes the window?
But how to check easily that unloading refers only to
windowclosing, not to following links to other admin subpages?
I have set up a disclaimer page for our public access PCs at our Libraries which has the following function:
function breach() {
alert("Proceeding beyond these Conditions is..................... If you have read the Conditions, scroll to the bottom and press the 'Yes I
agree' button.")
window.location="disclaim.htm"
and then in the body tag I have onunload=breach()
This works fine for all websites entered into the address bar except if
you enter www.google.com
What it is supposed to do is bring up the prompt and when you click on the OK button it will go back to the disclaimer page. They should only be able to get to the web by clicking on the 'Yes I
agree' button at the bottom of the disclaimer page. Does anyone out there know why google doesn't fire up the disclaim.htm page like all the other sites? It is very frustrating.
This error occurs ONLY in Netscape 7.0. Not in 7.1. So, I think it's a
bug. Buuuut...
Has anyone had this problem or know of a fix?
When attempting to have an onunload function set with "window.onload=",
the error comes up
"permission denied to set property window.onunload"
I can't find a thing on this one. Setting it with the normal "<body
onunload" works fine. But isn't a great thing for me to do, since the
onload is part of a very large menu script.
Here's a test page to illustrate the problem. Netscape 7.0 has a problem
with this. 7.1 does not. IE is fine, too. Code:
I have a site with 5000 pages.
I need to add the onbeforeunload event to the body tag of each form. How can i do this programatically using javascript.
i would like to loop through the form, find the body tag append the onbeforeunload event.
(also, i would like to all href's) on each page.
this is what i have so far but it does not bring the body tag or hrefs's
<code>
function GetElementsFromForm()
{
//document.formOne.elementOne
//document.forms[0].elements[0]
[Code]....
In windows7 RTM IE8 facing problem in onunload event. In onunload event I am trying to reset the cookies,also I am trying to end the session at the server side.For this I am submitting a form on onunload.Its working in all the other browsers. But in windows7 RTM IE8 I am getting ACCESS DENIED java script error.Someone have encountered the same problem
View 2 Replies View RelatedI'm having a hard time figuring out why the onload event is not being
called for the frameset window in the following simple example. It is
being called for each of the component frames. Code:
I wander what gets loaded the fastest (1-2 or 3) in what succession:
<head>
<script type="text/javascript">
function andAction() {
// doing stuff
}
</script>
</head>
<body onload="andAction();">
<script type="text/javascript">andAction()</script></body>
just in the head and nothing more
This I am sure off:
<head>
<script type="text/javascript">
window.onload = function andAction() {
// doing stuff
}
</script>
</head>
<script type="text/javascript">andAction()</script></body>
just in the head and nothing more (should be 1)
Third and last which is faster:
body onload or window.onload
I have some problem with onunload where I want slideUp my menu when I go out form site. I have the slideDown function fire at body onload and this function work properly. but the slideUp() at onunload not.
My code:
$(window).unload(function() {
$('#menuContent1').slideUp();
alert('Handler for .unload() called.');
});
and even the alert work. Only the jQuery slideUp not working.
I'm seeing a difference in behaviour between
window.onload = f();
and
<body onload="f();">
Specifically, window.onload appears to fire before all the elements of
the page have been rendered. As the difference is consistent across
IE/Moz/Opera, I'm assuming it's deliberate - can anyone point me
towards where this behaviour of window.onload is defined in the
documentation? TIA. Code:
I am trying to initiate fancybox popup on page unload (i.e. when the user closes the browser window). I managed to find the following script which does the opposite (launches when the page loads). How can I reverse this code so that it executes on body unload?
[Code]....
I'm trying to create a text field that, when two or more characters
are entered, the form is automatically submitted. The trouble I'm
having is knowing when the onSubmit handler is fired. It's supposed
to be executed when the form is submitted. I'm doing a submit via JS
which should cause the form to run the onSubmit handler. But, it
isn't. This leads me to believe that calling submit() is different
from a hard submit. True?
can anyone tell me why the second 'alert()' is not executed here?
The first 'alert()' pops up (so I know I am inside the 'if'), but not the
second one, and orderNum is not set....
Ive got the following code :
in aspx file
in head:
<script type="text/javascript">
function LoadBlocks() {
$(".LoadBlocks").click();
[Code]....
Like i said above when I call LoadBlocks function the click in executed in code behind but nothing else in the javascript function is beeing executed , not event an alert
I have the following code
Code:
function hideDisplaySingleSuite(textstring) {
var myclass1 = new RegExp('\b'+textstring+'\b');
//Populate the array with all the page tags
[Code].....
are executed, meaning that first the rows with a class is shown and then they are hidden.
i need to wrap the following code with (function($){ ... })(jQuery);But when i do so than the callbackfunction jsonpCallback will not be executed anymore.I hope someone can explain that to me...
// ( function($)
{$(document).ready(function() {
var error_container = $('#ul_demo_error')
[code]....