开发者

JavaScript: How to abort unload and making a JavaScript call?

开发者 https://www.devze.com 2023-02-22 04:00 出处:网络
I\'d like to make at evere onunload event a jQuery call which toggles a few divs in one开发者_开发百科 second. And then I\'d like to do the unload.

I'd like to make at evere onunload event a jQuery call which toggles a few divs in one开发者_开发百科 second. And then I'd like to do the unload.

How can I time out the unload for one second and make a jQuery call in this time?

Thanks for help!

Flo

EDIT:

Ok, I think, the most passable solution is instead of an usual link every link gets a javascript call like this:

<a href="link('http://google.ch')">Google</a>

And the Function link:

function link(param) {
    //Here a for loop to toggle all the divs what I wanted before...
    window.location=param;
}

But thanks for help ;)


beforeunload's event can only be halted with a blocking action such as alert(), prompt(), etc...

So if you tried to call a function in that event, it is most likely the browser will simply ignore it.

0

精彩评论

暂无评论...
验证码 换一张
取 消