2014-02-28 40 views
-1

我有这在左边框架,我想在其他框架的结果,我试了很多,但没有为我工作,任何帮助吗?onclick函数与iframes

<script type="text/javascript"> 
    function goToPage() { 
     var page = document.getElementById('datepicker').value; 
     window.location = "http://example.com"; 
    } 
</script> 

<p><b><font color="#FF0000" size="4">Date:</font></b> 
<input type="text" id="datepicker" size="20" name="datepicker" value="Date Field" maxlength="8"><input type="submit" value="submit" onclick="goToPage();" /></a></p> 
+2

我见代码示例中没有Iframe。 –

+0

可能的复制:http://stackoverflow.com/questions/7027799/access-elements-of-parent-window-from-iframe – Hackerman

回答

0

你需要,你要加载的URL的iframe的参考。

假设你的目标的iframe的id是 'targetIframe' 和jQuery是装上所有的内部框架,你可以从另一个IFRAME做到这一点:

var iframe = window.top.$('#targetIframe'); 
iframe.attr('src', url); 

你也可以这样做:

iframe.contentWindow.location = url;