开发者

Retrieve information from pop windows

Is there a way to popup a web page, and retrieve some information from the page a开发者_JAVA技巧s it is being closed or before being closed?

I have done me homework and know about jquery popups etc, but I want something I can learn the basics from.

/vfclists


document.body.unload = PageUnload;

function PageUnload{

 // this fires when the page is unloading

} 


Chris Ballance's answer demonstrates how you can have JavaScript call a function when a page is closed. That's part of what you need to do. The other part is getting the information out if it.

You don't say whether you want to get that information to the server, or get it to the page that launched the popup. If you want to get it back to the server, then you can use an asynchronous AJAX call. Just be aware that could introduce delays between when the user tries to close the window and when it actually goes away. I would have the PageUnload function change some text on the page to "Closing window..." or something to let the user know that "top men are working on it".

If you're trying to push the information to the other page, then you need to use window.opener or window.parent, depending on how the popup is launched. See the w3schools documentation for more information.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜