Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

After searching a lot over the internet I finally decided to post this question.

I am using THICKBOX jquery tabs.When any of the tab is clicked I want to pass the URL.IDNUMBER to the iframe which on tab pages . I was able to send the IDNUMBER and display it in a text box by simply using jquery on the main page

$("#mytest").val('IDNUMBER');

Tab Page:

<input id="mytest" name="IDNUMBER" type="text">

But am unable to pass the idnumber as a url parameter to the iframe.The tab page is an HTML page.

Thank You

share|improve this question
 
It would help if you pasted code. –  a paid nerd Nov 2 '09 at 21:09
 
Thickbox has been deprecated. It's much wiser to use a different solution for your modal lightboxes, now. –  Paul Irish Nov 2 '09 at 21:21

1 Answer

Today I faced the same problem. I solved it with the following approach:

<iframe id="inviteFriendsFrame" src ="location_to_iframe?paremater1=value1&parameter2=value2" width="529px" height="300"></iframe>

Then inside the iframe we can parse the GET from javascript, I've used this

http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html

function getUrlVars() { // Read a page's GET URL variables and return them as an associative array.
    var vars = [],
        hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

so then I had all the get variables and therefore could do so something like:

parameters = getUrlVars(); //which leads to:
console.log(parameters['param1']); //Writes 'value1' to console

Hope I've helped. Please note that although the link is from a jQuery site, the code is generic JavaScript.

share|improve this answer
 
This solution works only if the location_to_iframe does not do a automatic redirect, then you loose all the parameters. This happened to me, where I had a domain, and it was automatically redirecting to another page, depending on the country –  Gabriel Diaconescu Apr 4 '11 at 7:59
 
I think that the nature of the iframe is that it should be independent of the frame that hosts it. Therefore all the communication should be in the form of GET or POST values. Do you control what is going on the domain that causes the redirection? –  dimitris mistriotis Apr 4 '11 at 9:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.