使用Javascript在帧之间传递数据 [英] Passing data between frames with Javascript

查看:113
本文介绍了使用Javascript在帧之间传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 http://ryanmalin.co.uk/frames/

如果按添加,它会将左边框架中的表格数据粘贴到右边框架中。

If you press "add" it will paste the form data from the left frame into the right frame.

当我将右框架URL更改为另一个域的URL时,Firebug会抛出错误,但它不起作用。显示的错误是:

When I change the right frames URL to that of another domain Firebug throws an error and it doesn't work. The error shown is:


错误:访问属性'document'的权限被拒绝

Error: Permission denied to access property 'document'

是否可以使用frames / javascript将数据从我的域中的一个预先填写的表单复制到另一个域上的表单?

Is it possible to copy data from one pre-filled form on my domain to a form on another domain using frames/javascript?

我认为这是一种内置于浏览器或网站的反垃圾邮件措施,但如果可能的话,我需要绕过它。为了通过我的包裹递送公司发送客户订单,我一直在两个浏览器标签之间逐个复制每个地址字段 - 现在订单正在增加我需要加快这个过程,但是快递还没有办法发送所有的日子一次订购详细信息。

I believe it is an anti-spam measure built into browsers or websites but if possible I need to get around it. To send customer orders through my parcel delivery company I have been copying over each address field one by one between two browser tabs - now that orders are increasing I need to speed this process up, however the courier doesn't yet have a way of sending all of the days order details at once.

我可以编写获取左框架订单详细信息所需的PHP但不想浪费时间,如果不可能我做了什么。

I can write the PHP needed to grab the order details for the left frame but don't want to waste time if its impossible to do what Im after.

非常感谢:)

推荐答案

有关帧间安全性如何工作的说明,请参阅同源策略。简而言之,出于安全原因,在不同域上的帧之间允许的通信很少。你不能在不同域的帧之间进行任何直接的Javascript调用。

See the "Same Origin Policy" for a description of how inter frame security works. In a nutshell, there is very little communication allowed between frames on a different domain for security reasons. You cannot make any direct Javascript calls between frames on different domains.

HTML5有一个新的消息传递系统,可以安全地在不同的协作帧之间传递数据(而不是直接的JS调用)域。请参见此处这里描述了HTML5消息传递的工作原理。

HTML5 has a new messaging system that can safely communicate data (not direct JS calls) between cooperating frames in different domains. See here and here for a description of how the HTML5 messaging works.

这篇关于使用Javascript在帧之间传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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