Get data from an Iframe on a local webpage Get data from an Iframe on a local webpage
Posts 1 to 7 of 7
  1. #1

    More fingers than teeth

    xoggoth's Avatar
    Join Date
    Jul 2005
    Location
    xoggoth towers
    Posts
    14,258

    Default Get data from an Iframe on a local webpage

    Trying to get some data from an iframe and used the simple method in this link:

    How to get HTML content of an iFrame using JavaScript ? - GeeksforGeeks

    Works fine when the pages are on the website but, as it's just my mappy thing for personal use, I'd like it to work on my PC without having to upload it. However, I get "Blocked a frame with origin "null" from accessing a cross-origin frame"

    Any way round this? Cheers.
    bloggoth

    If everything isn't black and white, I say, 'Why the hell not?'
    John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

  2. #2

    Nice But Dim

    DaveB's Avatar
    Join Date
    Oct 2005
    Posts
    20,726

    Default

    Quote Originally Posted by xoggoth View Post
    Trying to get some data from an iframe and used the simple method in this link:

    How to get HTML content of an iFrame using JavaScript ? - GeeksforGeeks

    Works fine when the pages are on the website but, as it's just my mappy thing for personal use, I'd like it to work on my PC without having to upload it. However, I get "Blocked a frame with origin "null" from accessing a cross-origin frame"

    Any way round this? Cheers.
    Looks like it's being blocked at the browser level. You'd need to disable the same-origin policy in your browser settings to allow it, but thats generally a Bad Idea since it applies to all websites you visit, not just the ones you own, and exposes you to all sorts of potential nasties.

    EDIT : Can be done in all current browsers except Edge, if you are using that you're out of luck (but safe).
    "Being nice costs nothing and sometimes gets you extra bacon" - Pondlife.

  3. #3

    Super poster

    Hobosapien's Avatar
    Join Date
    Feb 2016
    Location
    LA - la la fantasy land
    Posts
    3,252

    Default

    See if can relax the browser security settings for local intranet sites (or deemed safe sites) so it works as you need while still protecting against dodgy external websites you may visit.

    Alternatively install a browser for local use only so can use in isolation of the properly set up main browser(s). At one time you could install multiple versions of Internet Explorer but not sure if modern browsers allow that so can use an older version for local stuff while keeping the latest version up to date security wise.
    Maybe tomorrow, I'll want to settle down. Until tomorrow, I'll just keep moving on.

  4. #4

    More fingers than teeth

    xoggoth's Avatar
    Join Date
    Jul 2005
    Location
    xoggoth towers
    Posts
    14,258

    Default

    Cheers chaps.

    thats generally a Bad Idea since it applies to all websites you visit, not just the ones you own, and exposes you to all sorts of potential nasties
    Yeh, saw that solution but was dubious for that reason.

    Alternatively install a browser for local use only so can use in isolation of the properly set up main browser(s
    Got Brave, Opera & Firefox installed but never use them. May try those.

    Wonder why pages in same local folder are a problem. Annoying. Even pro developers may initially use local files for testing.
    Last edited by xoggoth; 18th November 2020 at 15:44.
    bloggoth

    If everything isn't black and white, I say, 'Why the hell not?'
    John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

  5. #5

    More fingers than teeth

    xoggoth's Avatar
    Join Date
    Jul 2005
    Location
    xoggoth towers
    Posts
    14,258

    Default

    Seems to work in Firefox. May be out of date version tho. Googling "same-origin policy" brings up quite a few interesting things.
    Last edited by xoggoth; 18th November 2020 at 16:06.
    bloggoth

    If everything isn't black and white, I say, 'Why the hell not?'
    John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

  6. #6

    More time posting than coding

    darrylmg's Avatar
    Join Date
    Sep 2012
    Location
    UK - South West
    Posts
    284

    Default

    Quote Originally Posted by xoggoth View Post
    Trying to get some data from an iframe and used the simple method in this link:

    How to get HTML content of an iFrame using JavaScript ? - GeeksforGeeks

    Works fine when the pages are on the website but, as it's just my mappy thing for personal use, I'd like it to work on my PC without having to upload it. However, I get "Blocked a frame with origin "null" from accessing a cross-origin frame"

    Any way round this? Cheers.
    You could setup a reverse proxy with url mapping.
    You'd need a local www server running on your pc to host your local js (apache could do both of the above).

    Then when accessing the proxy, your browser would see both targets ( the external website & your local website) under the same domain and allow the resource requests.
    Don't believe it, until you see it!

  7. #7

    More fingers than teeth

    xoggoth's Avatar
    Join Date
    Jul 2005
    Location
    xoggoth towers
    Posts
    14,258

    Default

    Cheers. Probably not worth the hassle for my purposes, it's only a minor feature I'm trying to add, but I'll have a look.
    bloggoth

    If everything isn't black and white, I say, 'Why the hell not?'
    John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •