Argh! Calling parent functions from a page within an iframe

  • pompei
  • Graduate
  • Graduate
  • pompei
  • Posts: 117

Post 3+ Months Ago

Hi everyone,

This is currently getting me pulling my hair out. I want to be able to call a function on a page from a page within an iframe on that page. e.g.:

Parent document (siteX.com):

Code: [ Select ]
<script language="Javascript">
function test() { alert('test works'); };
</script>

.. some html

<iframe src="http://siteY.com/page_y.htm"></iframe>
  1. <script language="Javascript">
  2. function test() { alert('test works'); };
  3. </script>
  4. .. some html
  5. <iframe src="http://siteY.com/page_y.htm"></iframe>


And then on page_y this code should work:

Code: [ Select ]
<script language="Javascript">
parent.test();
</script>
  1. <script language="Javascript">
  2. parent.test();
  3. </script>


The problem is, this works when both pages are part of the same site, but not when page_y is on a different site than the one that places it in an iframe.

Any help!?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

I don't think this is possible when the document is on a different site. This came up in a different thread a while back. After some research we came across a document at Microsoft that explains that cross-frame scripting between domains in not allowed for security reasons.

The article is here:

http://msdn.microsoft.com/library/defau ... curity.asp
  • pompei
  • Graduate
  • Graduate
  • pompei
  • Posts: 117

Post 3+ Months Ago

Hey RichB,

Thanks for the thread, I had a hunch it wasn't possible :cry:

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: wpas and 73 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.