Javascript detect closing popup loaded with another domain

前端 未结 4 1008
猫巷女王i
猫巷女王i 2020-12-04 20:29

I am opening a popup window and attaching an onbeforeunload event to it like this:

win = window.open(\"http://www.google.com\", \"\", \"width=300px,height=30         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 20:57

    Unfortunately, you're trying to communicate across domains which is prohibited by JavaScript's same origin policy. You'd have to use a server-side proxy or some other ugly hack to get around it.

    You could try creating a page on your site that loads the external website in an iframe. You could then pop open that page and listen for it to unload.

提交回复
热议问题