2

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

mplungjan
  • 134,906
  • 25
  • 152
  • 209

3 Answers3

1

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

mplungjan
  • 134,906
  • 25
  • 152
  • 209
Valentin Kantor
  • 1,543
  • 1
  • 21
  • 26
  • But that would make a nasty blink I think - and I cannot change to about:blank UNLESS the child frame told me it needed changing! – mplungjan Feb 24 '11 at 17:25
  • 1
    it's only way get window.name data from iframe. but you always can use other ways for implementing crossdomain ajax requests – Valentin Kantor Feb 24 '11 at 18:06
  • I know all about that. This is a script where the iframe goes to an anchor and the parent frame needs to scroll to the top when the iframe changes – mplungjan Feb 24 '11 at 20:20
  • may be you can define function in parent window "scroll_to_top", and in iframe attach event to label, like this **$("#label_id").click(function(){window.parent.scroll_to_top(params) }) ** i didn't try this code, but thik it can work – Valentin Kantor Feb 24 '11 at 21:58
  • Ahem nope. If I could I would not bother with the window.name rigamarole. – mplungjan Feb 25 '11 at 06:14
1

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.

Sean Kinsey
  • 35,601
  • 7
  • 49
  • 68
  • Still get HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. – mplungjan Mar 17 '11 at 07:56
  • It's up, and you should never have received a 404 anyway... http://downforeveryoneorjustme.org/easyxdm.net – Sean Kinsey Mar 17 '11 at 10:23
  • Their DEMO: If you want to see it in action, [see this RPC demo!](http://easyxdm.net/Method%20not%20returning%20any%20data) – mplungjan Mar 17 '11 at 10:40
  • Thanks... Is there a server proxy involved somewhere there? – mplungjan Mar 17 '11 at 14:37
  • There are no proxies involved - everything happens in the browser between the two domains. There's a reason why Twitter, Disqus and more are using it :) – Sean Kinsey Mar 17 '11 at 15:17
  • @Sean So if you take my example what exactly would I need to do? – mplungjan Mar 17 '11 at 17:11
  • @mplungjan First I need to know what you are actually trying to do - monitoring the name property is only the means, not the goal right? – Sean Kinsey Mar 17 '11 at 20:37
  • Yes. The goal is to know when the iframe has changed so the top frame can move to top – mplungjan Mar 18 '11 at 08:57
  • Yes to what? It was not a yes/no question. Point is - you cannot read the name of a window who's document comes from a different domain. But if you need cross-domain communication, then you can use easyXDM for this. – Sean Kinsey Mar 18 '11 at 10:01
  • `Yes it is only the means not the goal`. That is the yes answer to your yes/no question. – mplungjan Mar 18 '11 at 21:19
0

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.

Community
  • 1
  • 1
Chris Jacob
  • 10,898
  • 7
  • 45
  • 42