0

I have a dynamically created iframe

this iframe has js code

<script type="text/javascript"> if (window.devicePixelRatio >= 2) { document.body.className += ' is_2x'; } domReady(); Subscribe.init({id: 0, hash: '6ec859bd0192095f3b', oid: 15898180});;vk.id = 0; </script> 

i need get the Subscribe.init() value from parent window

thanks

ps. I don't have edit permissions to this iframe. I need this value like text

2
  • I think this is not possible for security-reasons in most browsers. If it was possible, an iFrame you put into your webpage (for example a youtube video) could interfer with your main-pages scripts and contents, doing all kind of evil stuff. Commented Jul 14, 2013 at 20:54
  • assuming no CORs is available and your apps on on different domains, JSON.stringify the data and append it to the url hash of the iframe from the parent. in the frame, you can JSON.parse(location.hash.slice(1)) to get the object back. you can also use the "window.name" hack, or postMessage(). Commented Jul 14, 2013 at 21:00

1 Answer 1

2

Assuming you don't run into Cross Domain Scripting issues (IFRAME is within the same domain as the parent window, or CORS is enabled and configured), you can try:

window.parent.Subscribe.init({id: 0, hash: '6ec859bd0192095f3b', oid: 15898180}); 

More about security issues you may encounter: http://en.wikipedia.org/wiki/Same_origin_policy

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.