Jump to content
  • 0

How To Pass Browser Parameter Into An Iframe




I was searching for a solution to pass browser parameter into another html page inside an iframe and I stumbled on a neat code and tweaked it.   It worked for me so I'm sharing this here.

            <iframe src="ParamCatch.html" width="100%" height="500" type="text/html" frameborder="0"  style="border: 0">
        <script type="text/javascript">
        var form = 'ParamCatch.html';
        var params = window.location.search;
        var thisScript = document.scripts[document.scripts.length - 1];
        var iframe = document.createElement('iframe');

        iframe.setAttribute('src', form + params);
        iframe.setAttribute('width', '100%');
        iframe.setAttribute('height', 500);
        iframe.setAttribute('type', 'text/html');
        iframe.setAttribute('frameborder', 0);
        iframe.setAttribute('allowTransparency', 'true');
        iframe.style.border = '0';

        thisScript.parentElement.replaceChild(iframe, thisScript);


My Test:
- Two HTML pages, Main.html and ParamCatch.html

ParamCatch.html contains the embedded DataPage set to receive parameter as filter for Tabular Report

  > contains the script above
  > tested using Main.html?paramname=paramvalue
  > ParamCatch.html got the parameters and displayed the correct data



Link to post
Share on other sites

1 answer to this question

Recommended Posts


I tried this but it doesn't work. My form disappeared and nothing was displayed on the screen. I used the above code in my webpage that had the embedded Caspio datapage which was displaying the Caspio form.

What do you use for the URL? Is it the target URL of my Web page?



Link to post
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...