...

View Full Version : Help with Window.Onload



rihaszou
11-24-2008, 03:41 PM
I have a function and the purpose of the function is to get two variables, pc1 and pc2. They are both getting their data from the same text box. pc1 should get the data when the page is onload, and pc2 should get it when the page is onbeforeunload. I have them in the same function so I can compare them, see if anything has changed, and then ask the user if they want to save. The problem I am having is distinguishing between which event the function has fired for:

window.onload = func();
windown.onbeforeunload = func();

function func()
{
if (//some code needed here to see if its onload)
var pc1 = textbox info
if (//some code needed here to see if its onbeforeunload)
var pc2 = textbox info

if (pc1 ==pc2)
(do something)
}

any help would be appreciated...

}

A1ien51
11-24-2008, 05:20 PM
window.onload = func();
windown.onbeforeunload = func();


func() means to execute right than and there.

You need to attached it without the ()



window.onload = func;
windown.onbeforeunload = func;


Eric

Arty Effem
11-26-2008, 01:57 AM
The problem I am having is distinguishing between which event the function has fired for:You could try:
window.onload = function(){func(true);}
windown.onbeforeunload = function(){func(false)};

function func(flag)
{
.............
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum