0

I am trying to set up an app which gets the URL of a webpage however the webpage in the iframe is an external site. Based on the URL, it will trigger something to load on the page for the user.

I have tried using the following code:

$("iframe").contents().get(0).location.href;

However, the return result is about:blank. I have full access to both the local and the external server if I need to make a change to them to get this working.

If I use the above code where the iframe is loading a page on the same server, it works perfectly fine.

James
  • 406
  • 1
  • 3
  • 12
  • 1
    Take a look at using postMessage api to update parent page from frame pages when they load – charlietfl Mar 23 '21 at 12:03
  • Have a look at this answer: https://stackoverflow.com/a/938195/2148605 jQuery is just a JavaScript library, so the same restrictions apply. I'm a bit pessimistic but you may be able to set a site-specific security exception in your browser. – Ashley Miller Mar 23 '21 at 12:43

0 Answers0