2

I have an iframe that is loaded on web page and I do not have permissions to access the parent page. I have access to the iframe's code. I would like to access one of the parameters of this iframe. What is the best way to achieve this?

I tried location.search but it does not give me all the parameters.

Any suggestions? Cheers.

Neophile
  • 5,660
  • 14
  • 61
  • 107
  • Have you checked the other properties of the location object? ( href, protocol, hash, host, ... ) https://developer.mozilla.org/en-US/docs/Web/API/Location – Shilly Aug 19 '16 at 15:25
  • Yup, I have checked. None of those properties have that parameter. – Neophile Aug 19 '16 at 15:27
  • 1
    When do we know that the iframe has loaded completely? I am currently using $(window).load(function() {}); to identify that. – Neophile Aug 19 '16 at 15:31
  • Can you show some examples of what you have tried? What are the parameters returned? What is the actual URL? What are the expected parameters? – 10100111001 Aug 19 '16 at 15:53
  • window.location gives the location of the parent URL not the iframe URL. – Neophile Aug 19 '16 at 16:04

1 Answers1

4

I managed to find the answer myself and we can retrieve the iframe's URL using the following code:

document.location.href

This seems to work fine without any issues.

Neophile
  • 5,660
  • 14
  • 61
  • 107