Cross domain access to iframe using window.name

2019-07-17 01:38发布

问题:

I implemented a script that monitors the iframe name as I understood was OK from various sources on the net. However it seems I must have gotten something wrong - I get

Error: Permission denied to access property 'name'
Source File: http://plungjan.name/test/testwindowname.html
Line: 16

Please visit http://plungjan.name/test/testwindowname.html

I would prefer just to fix my script and not use jQuery or DOJO or some other framework. Thanks

回答1:

as I remember you must change iframe location to "about:blank" and after it you can access to its window.name property



回答2:

Is it cross-domain communication you need here, or just the name of the window?

If the first one, take a look at easyXDM - it abstracts away all the hassle with XDM across browsers ranging from IE6 to Chrome10.



回答3:

Take a look at this question:

Resizing an iframe based on content

Has a Cross Domain solution ... but you need to have access to both the servers to implement this solution.