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.
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.
Share Improve this question asked Aug 19, 2016 at 15:22 NeophileNeophile 5,89017 gold badges62 silver badges107 bronze badges 5- Have you checked the other properties of the location object? ( href, protocol, hash, host, ... ) developer.mozilla/en-US/docs/Web/API/Location – Shilly Commented Aug 19, 2016 at 15:25
- Yup, I have checked. None of those properties have that parameter. – Neophile Commented Aug 19, 2016 at 15:27
- 1 When do we know that the iframe has loaded pletely? I am currently using $(window).load(function() {}); to identify that. – Neophile Commented Aug 19, 2016 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 Commented Aug 19, 2016 at 15:53
- window.location gives the location of the parent URL not the iframe URL. – Neophile Commented Aug 19, 2016 at 16:04
1 Answer
Reset to default 4I 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.