admin管理员组文章数量:1356444
This is the setup:
I have two websites on two different domains:
www.website1
www.someotherwebsite
This is what I want to do:
When a user is on
www.website1
and clicks a link, I want a window to popup showingwww.someotherwebsite
.When the user clicks a button in the popup window (showing
www.someotherwebsite
) I want that window to close and have a value returned.I want the value returned from the popup window to be placed (into a div, or into a javascript call, or someplace accessible such as filling out a form field) on
www.website1
.
I hope that makes sense. I need to use just HTML and Javascript without external libraries. It also must work on current mainstream browsers (i.e. not be an HTML5 thing).
Thank you in advance for your help.
This is the setup:
I have two websites on two different domains:
www.website1.
www.someotherwebsite.
This is what I want to do:
When a user is on
www.website1.
and clicks a link, I want a window to popup showingwww.someotherwebsite.
.When the user clicks a button in the popup window (showing
www.someotherwebsite.
) I want that window to close and have a value returned.I want the value returned from the popup window to be placed (into a div, or into a javascript call, or someplace accessible such as filling out a form field) on
www.website1.
.
I hope that makes sense. I need to use just HTML and Javascript without external libraries. It also must work on current mainstream browsers (i.e. not be an HTML5 thing).
Thank you in advance for your help.
Share Improve this question asked Sep 18, 2009 at 8:03 user5722user5722 1,2943 gold badges10 silver badges13 bronze badges 02 Answers
Reset to default 3Well if you use an iframe in your pop up window [in this day in age I would avoid pop up windows like the plague due to pop up blockers]
With an iframe you can make cross domain calls
Why don't you just develop a webservice from A to B and call it from A? Seems so much cleaner than finding small cracks in browsers to get around security.
You could post the value in the popup from www.someotherwebsite. back to a special page on www.website1.. Now you're back into the original domain, that page takes the GET value and writes it out into some JavaScript. The JavaScript then updates the value somewhere in the opener window use opener.document.getElementById, or calls a function in the opener with something like opener.document.doSomething(val); which handles the response.
It's fraught with potential errors (what if the user opens two copies of the window? Or closes the original site?) and potential security holes, and browsers have a tendency to react badly if you try to do things to windows that don't exist or are in different domains, but in a known environment it should work.
本文标签: javascriptCross domain popup window with return valueStack Overflow
版权声明:本文标题:javascript - Cross domain popup window with return value - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743995646a2572939.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论