1

I have a page that takes a parameter: http://example.com/mypage.html?param=123

Inside the html I have an iframe that needs that parameter, something like that:

<iframe src="http://example.com/myapp?id=123" etc...>

Now I know how to parse the parameter from the url, and I can change the src for the iframe in the onload(). But the problem is that iframe is first displays w/o the parameter (that displays some default iframe), then after onload it will display correctly.

Can I show the iframe with the parsed parameter right at load time? (No php, javascript only)

laszlo
  • 101
  • 1
  • 4
  • Possible duplicate of [How to pass parameters through iframe from parent html?](http://stackoverflow.com/questions/28295870/how-to-pass-parameters-through-iframe-from-parent-html) – Laim McKenzie Sep 11 '16 at 17:23
  • This is not a duplicate of the above. – laszlo Sep 11 '16 at 20:20

1 Answers1

1

Looks like the solution is to add the javascript in the body like that:

<script>
    var sid = location.search.substr(location.search.indexOf("sid=")+4);
    var ifrm = document.getElementById('myiframe') ;
    var target = "http://example.com/myApp?sid=" + sid;
        ifrm.setAttribute('src', target);       
</script>
laszlo
  • 101
  • 1
  • 4