试试这个
index.html 有一个指向 careers.html 的链接。careers.html 上有一个 I 框架。所以你想设置 iframe 目标。也。
所以你在主页上的链接需要看起来像:
<a href="careers.html?iframe_targ=page_for_iframe.html">Click here</a>
careers.html 需要有
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
以上代码改编自How can I get query string values in JavaScript?
$('iframe#foo').attr('src', getParameter("iframe_targ"));