Javascript 使用加载程序链接选项设置动态iframe src?

Javascript 使用加载程序链接选项设置动态iframe src?,javascript,jquery,html,iframe,Javascript,Jquery,Html,Iframe,我想让我们的网页,包含一个iframe开关将有一个动态Src。因此,Scr将从网页链接开始固定。因此,当有人访问该网页(即iframe)时,将单击此链接: Link: http://"somedomain.com/ 但是我想要的是,通过这个链接修改该页面中的iframe Src。所以链接是这样的 Link: http://"somedomain.com/?s=specified_source_of_the_iframe 这样,iframe将通过变量“s”获取指定的源。 “s”可以是一个链接,

我想让我们的网页,包含一个iframe开关将有一个动态Src。因此,Scr将从网页链接开始固定。因此,当有人访问该网页(即iframe)时,将单击此链接:

Link: http://"somedomain.com/
但是我想要的是,通过这个链接修改该页面中的iframe Src。所以链接是这样的

Link: http://"somedomain.com/?s=specified_source_of_the_iframe
这样,iframe将通过变量“s”获取指定的源。 “s”可以是一个链接,也可以只是一个变量名

我在想的是,如何解决这个问题

<body onload="Setiframe();">
<iframe id="iframe" name="iframe" src=""></iframe>
<script>
function Setiframe(){
document.getElementById('iframe').setAttribute("src",s);
//or if "s" was a variable, it will be a link. or other method. it's not a problem for me. the problem's to access to the link data
}

函数Setiframe(){
document.getElementById('iframe').setAttribute(“src”,s);
//或者如果“s”是一个变量,它将是一个链接。或者其他方法。这对我来说不是问题。问题是访问链接数据
}
我知道这与PHP有关,但我对PHP一无所知。我不想用它,因为我的网页快完成了


请注意,任何建议都会很有帮助

您可以访问包含查询字符串的位置对象的搜索属性,然后对其进行处理以获得您想要的内容,特别是针对您的测试字符串(http://“somedomain.com/?s=指定的\u iframe的\u source\u),此功能:

function setIframe() {//I used a diferent function name ! check it! :)
   var s = location.search;
   s = s.replace('?s=', '');
   document.getElementById('iframe').setAttribute("src", s);
}

我想你可以做我想做的!所以提示是使用location.search。我将进行一些搜索以了解更多信息。再想一想你