Accessing a tag from an iFrame to its parent

Andrew Walker

I have seen a few example posts of this, but I seem to be a little stumped why none of them work.

Here is a stack view of what I am trying to achieve:

<html>
    <head>...</head>
    <body>
    <div>Some stuff, images, text</div>
    <div><audio id="audio"><source> src="me.mp3" /></audio></div>
    <div>Some stuff, images, text</div>
    <div>
        <iframe src="file.html">
          #document
            <html>
                <head>...</head>
                <body>
                    <div><button id="stopPlay">Stop Play</button></div>
                </body>
            </html>
        </iframe>
    </div>
    <div>Some stuff, images, text</div>                

    </body>
</html>

It has been suggested that to access the audio tag, you would use something like:

window.parent.document.getElementById('audio');

Which gives me an origin error, even though both files are on the same server. So I add, again as suggested document.domain = "[email protected]" and place this within the iframe, and parent. But still gives me an error that relates to the DOM.

As I am looking to go up the stack, and then search down it to find the element, how would I go about doing this, when other suggests have worked for others ?

Patrick

The only way I was able to reproduce this error is when using the local file system, It seems you're trying to access your html file from the local file system.

file://c:/wamp/www/foo.htm - that's the only way I could find to reproduce this, and this is a known bug for chrome. Also makes sense in some regrd, as there is no domain, thus the origin is null

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Accessing parent window from facebook iframe

From Dev

Jquery accessing $(parent.document).scrollTop from iFrame and SOP

From Dev

Accessing a DOM attached function in an iframe from the parent window

From Dev

Accessing Parent global variable in iFrame url

From Dev

JQuery Get Parent URL in IFrame:iframe and its parent are in Different domain

From Dev

Accessing a property from its attribute

From Dev

How to just scroll the iframe but not its parent?

From Dev

Script tag inside iframe executes on parent dom

From Dev

Accessing itemControllers from parent controller

From Dev

Resize iframe and its parent height according to content inside iframe

From Dev

Prevent Iframe from Reloading the Parent

From Dev

Blocked from accessing an Iframe with origin 'null'

From Dev

Fancybox (jQuery) - Passing information from parent to iframe and iframe back to parent

From Dev

how to delete a node in a linked list without accessing its parent node?

From Dev

Isolating subquery from its parent

From Dev

Accessing a cv::Mat independently from its size

From Dev

Get innerText from iframe from parent

From Dev

Accessing an attribute from a nested tag XSLT

From Dev

Accessing static files from custom template tag

From Dev

Accessing static files from custom template tag

From Dev

Accessing parent route slug from route

From Dev

Accessing parent view from modal segue Swift

From Dev

Accessing fragment methods from parent Activity

From Dev

Accessing derived class names from the parent class

From Dev

Accessing state of children from parent component?

From Dev

Accessing parent's namescope from a child

From Dev

Accessing child variables from parent class?

From Dev

Accessing "this" as the parent from callbacks emberjs nested component

From Dev

Accessing the computed properties of components in Vue from the parent

Related Related

  1. 1

    Accessing parent window from facebook iframe

  2. 2

    Jquery accessing $(parent.document).scrollTop from iFrame and SOP

  3. 3

    Accessing a DOM attached function in an iframe from the parent window

  4. 4

    Accessing Parent global variable in iFrame url

  5. 5

    JQuery Get Parent URL in IFrame:iframe and its parent are in Different domain

  6. 6

    Accessing a property from its attribute

  7. 7

    How to just scroll the iframe but not its parent?

  8. 8

    Script tag inside iframe executes on parent dom

  9. 9

    Accessing itemControllers from parent controller

  10. 10

    Resize iframe and its parent height according to content inside iframe

  11. 11

    Prevent Iframe from Reloading the Parent

  12. 12

    Blocked from accessing an Iframe with origin 'null'

  13. 13

    Fancybox (jQuery) - Passing information from parent to iframe and iframe back to parent

  14. 14

    how to delete a node in a linked list without accessing its parent node?

  15. 15

    Isolating subquery from its parent

  16. 16

    Accessing a cv::Mat independently from its size

  17. 17

    Get innerText from iframe from parent

  18. 18

    Accessing an attribute from a nested tag XSLT

  19. 19

    Accessing static files from custom template tag

  20. 20

    Accessing static files from custom template tag

  21. 21

    Accessing parent route slug from route

  22. 22

    Accessing parent view from modal segue Swift

  23. 23

    Accessing fragment methods from parent Activity

  24. 24

    Accessing derived class names from the parent class

  25. 25

    Accessing state of children from parent component?

  26. 26

    Accessing parent's namescope from a child

  27. 27

    Accessing child variables from parent class?

  28. 28

    Accessing "this" as the parent from callbacks emberjs nested component

  29. 29

    Accessing the computed properties of components in Vue from the parent

HotTag

Archive