带返回值的跨域弹窗 [英] Cross domain popup window with return value

查看:27
本文介绍了带返回值的跨域弹窗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是设置:

我在两个不同的域上有两个网站:

  • www.website1.com
  • www.someotherwebsite.com

这就是我想做的:

  1. 当用户在 www.website1.com 上并单击链接时,我希望弹出一个显示 www.someotherwebsite.com 的窗口..p>

  2. 当用户单击弹出窗口中的按钮(显示 www.someotherwebsite.com)时,我希望该窗口关闭并返回一个值.

  3. 我希望将弹出窗口返回的值放在 www.website1.com.

我希望这是有道理的.我只需要使用没有外部库的 HTML 和 Javascript.它还必须适用于当前的主流浏览器(即不是 HTML5 的东西).

提前感谢您的帮助.

解决方案

好吧,如果你在弹出窗口中使用 iframe [在这个时代,我会避免像瘟疫那样弹出窗口,因为弹出窗口阻止程序]

使用 iframe,您可以进行 跨域调用

你为什么不开发一个从 A 到 B 的 web 服务并从 A 调用它?似乎比在浏览器中发现小裂缝来绕过安全性要干净得多.

This is the setup:

I have two websites on two different domains:

  • www.website1.com
  • www.someotherwebsite.com

This is what I want to do:

  1. When a user is on www.website1.com and clicks a link, I want a window to popup showing www.someotherwebsite.com.

  2. When the user clicks a button in the popup window (showing www.someotherwebsite.com) I want that window to close and have a value returned.

  3. 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.com.

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.

解决方案

Well 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.

这篇关于带返回值的跨域弹窗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆