לאתר זה תהיה פונקציונליות מוגבלת בזמן שאנו מתחזקים אותו לשיפור החוויה שלך. אם מאמר מסויים לא פותר את הבעיה שלך וברצונך לשאול שאלה, קהילת התמיכה שלנו מחכה לעזור לך ב־Twitter תחת ‎@FirefoxSupport וב־Reddit תחת ‎/r/firefox.

חיפוש בתמיכה

יש להימנע מהונאות תמיכה. לעולם לא נבקש ממך להתקשר או לשלוח הודעת טקסט למספר טלפון או לשתף מידע אישי. נא לדווח על כל פעילות חשודה באמצעות באפשרות ״דיווח על שימוש לרעה״.

מידע נוסף

Cross-Origin Resource Sharing. Added header 'Access-Control-Allow-Origin' in response header for iframe data. Can parent page now manipulate iframe's DOM ?

  • 1 תגובה
  • 2 have this problem
  • 1 view
  • תגובה אחרונה מאת guigs

more options

Let say, I have a page on domain www.a.b.xyz.com. This page contains an iframe, with data from www.d.xyz.com.

iframe is loaded with data from www.d.xyz.com, by submitting html form to host www.d.xyz.com. In return server www.d.xyz.com is returning HTML DOM to be rendered in iframe. Server also sets header 'Access-Control-Allow-Origin: *.xyz.com' in response.

iframe is loaded with HTML DOM from www.d.xyz.com.

Now, I'm trying to access/manipulate (for eg: Click a button in iframe) DOM from parent page using Javascript. But, I'm not able to do so.

Is it because, 'Access-Control-Allow-Origin: *.xyz.com' just informs browser to show/render the content from www.d.xyz.com on www.a.b.xyz.com, but do not grant permission to parent page to manipulate iframe's DOM ?

I am able to manipulate iframe's DOM from parent, only if I create sub-domain for both parent and iframe- document.domain='xyz.com'; I changed domain using firebug debugger.

Any help will be appreciated.

Let say, I have a page on domain www.a.b.xyz.com. This page contains an iframe, with data from www.d.xyz.com. iframe is loaded with data from www.d.xyz.com, by submitting html form to host www.d.xyz.com. In return server www.d.xyz.com is returning HTML DOM to be rendered in iframe. Server also sets header 'Access-Control-Allow-Origin: *.xyz.com' in response. iframe is loaded with HTML DOM from www.d.xyz.com. Now, I'm trying to access/manipulate (for eg: Click a button in iframe) DOM from parent page using Javascript. But, I'm not able to do so. Is it because, 'Access-Control-Allow-Origin: *.xyz.com' just informs browser to show/render the content from www.d.xyz.com on www.a.b.xyz.com, but do not grant permission to parent page to manipulate iframe's DOM ? I am able to manipulate iframe's DOM from parent, only if I create sub-domain for both parent and iframe- document.domain='xyz.com'; I changed domain using firebug debugger. Any help will be appreciated.

השתנתה ב־ על־ידי binit.00354

כל התגובות (1)

more options

It sounds like you are running into this restriction and are looking for a work around: security.fileuri.strict_origin_policy preference, which defaults to true

I am not entirely sure if the subdomain counts a the same origin, but you can try location set. But an even better example: https://developer.mozilla.org/en-US/A.../Cross_Domain_Content_Scripts#Cross-domain_iframes

So your original question: Can parent page now manipulate iframe's DOM ? Sort of.


References: