[Last Call] Learn how to a build a cloud-first strategyRegister Now


Pass Query String from IFrame into Form Fields

Posted on 2010-01-07
Medium Priority
Last Modified: 2012-05-08
I have an Iframe embedded in my web page.   Inside the Iframe is a remote website with hyperlinks.  When I click on the link in the Iframe I would like to copy the query string parameters to form fields on my parent page.  

There are 2 parameters I need to copy to my form fields, layer and region. The links look like this: remotepage.html?layer=x&region=y

Is this even possible?

If so, can someone provide some example code?
Question by:mrotstein
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 26198415
when you click on a link call this javascript

function fetchValues( obj )
   var link = obj.href;
   var re = new RegExp("?", "g");
   var myArray = link.split(re); \\seperating out param and URL
   re = new RegExp("&", "g");
   myArray = myArray[1].split(re);  \\now you will get the key value pair

  \\loop through the key-values and put those values in the form of the document.

   \\open the new link  
   \\either in a seperate pop up

   \\or in the same screen
   locatiion.href = link;

let me know if this was helpful
LVL 22

Expert Comment

ID: 26198583
try this if you are using ASP

<iframe src="http://yahoo.com?<%=Request.QueryString()%>"></iframe>
LVL 75

Accepted Solution

Michel Plungjan earned 2000 total points
ID: 26199270
1. short answer: Not possible
2. longer version: have a proxy on your site read and present the content of the foreign site in the iframe with added onclick event handlers to pass data to the parent window which is now possible since both parent and iframe content is from same server, protocol and portnumber.
3. If you have access to the iframe content, you MAY be able to add the stuff you want to window.name and poll that from the parent.

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question