经过互联网搜索后,我终于决定发布这个问题了。
我正在使用THICKBOX jquery选项卡。当点击任何标签时,我想将URL.IDNUMBER传递给标签页上的iframe。 我能够发送IDNUMBER并在主页上使用jquery在文本框中显示
$("#mytest").val('IDNUMBER');
标签页:
<input id="mytest" name="IDNUMBER" type="text">
但是我无法将idnumber作为url参数传递给iframe。标签页是一个HTML页面。
谢谢
答案 0 :(得分:6)
今天我遇到了同样的问题。我用以下方法解决了这个问题:
<iframe id="inviteFriendsFrame" src ="location_to_iframe?paremater1=value1¶meter2=value2" width="529px" height="300"></iframe>
然后在iframe中我们可以从javascript解析GET,我已经使用了这个
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;
}
所以我得到了所有的变量,因此可以这样做:
parameters = getUrlVars(); //which leads to:
console.log(parameters['param1']); //Writes 'value1' to console
希望我帮助过。请注意,尽管链接来自jQuery站点,但代码是通用JavaScript。