Capture incoming URL Parameters, then pass to iFrame Src with Javascript Capture incoming URL Parameters, then pass to iFrame Src with Javascript javascript javascript

Capture incoming URL Parameters, then pass to iFrame Src with Javascript


This little snippet should do, here all you have to do is grab the bit after ? as a string and append it to the iframe source.

var loc = window.location.toString(),    params = loc.split('?')[1],    iframe = document.getElementById('myIframe');iframe.src = iframe.src + '?' + params;​​​​​​​​​​​​​​​​


Just use window.location.search.

const iframe = document.getElementById('frame');iframe.src = iframe.src + window.location.search;​​​​​​​​​​​​​​​​