Jump to content
  • 0

How To Pass Browser Parameter Into An Iframe


Ba2sai

Question

Hey,

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.
http://help.pardot.com/customer/portal/articles/2126647-passing-url-parameters-from-browser-to-iframe
 

    <noscript>
            <iframe src="ParamCatch.html" width="100%" height="500" type="text/html" frameborder="0"  style="border: 0">
            </iframe>
        </noscript>
    
        <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);
        </script>

 

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

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

 

Cheers!

Link to post
Share on other sites

1 answer to this question

Recommended Posts

Hi,

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?

 

Thanks.

Link to post
Share on other sites

Archived

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

×
×
  • Create New...