4

I have an iframe. When the page loads, the page makes a queryString.

I need to access the query string that is generated after the page is loaded

But with this code just I can access the src without the query string

alert(document.getElementById('myframe').src);
Der Vampyr
  • 941
  • 1
  • 7
  • 13
محمد
  • 139
  • 3
  • 11

1 Answers1

1

Try:

document.getElementById("myframe").contentWindow.location.href

where myframe is the id of the frame

AndreiC
  • 542
  • 4
  • 16
  • get this errror in console : Uncaught TypeError: Cannot read property 'myframe' of undefined htmlpage.html:121getiframeURL htmlpage.html:121onclick htmlpage.html:130 screanshot : http://www.xum.ir/image/bLMC – محمد Nov 19 '14 at 12:55
  • works for me, try this: `alert(document.getElementsByTagName('iframe')[0].contentWindow.location.href);` – Martin Filek Apr 06 '21 at 11:29