1
例如,如果我的iframe设置为google.com,则有人在iframe中进行搜索,并将其加载到iframe中。我想在iframe下面有一个链接,上面写着类似“转到页面”的链接。当他们点击它时,它不会将它们一定带到google.com,而是带到iframe中当前所处的任何页面。我试着用下面的代码无济于事:如何创建一个链接到iframe的当前位置?
<iframe id=frame src="http://www.google.com" scrolling=yes></iframe>
<a id=moveOn href=# onclick='return false'>Click to go to page</a>
<script>
$('#moveOn').click(function(){
var src = document.getElementById('frame').contentDocument.location;
window.open(src);
});
</script>
有什么建议吗?谢谢:)
[这太问题将可能是你的兴趣。(http://stackoverflow.com/questions/44359/how-do-i-get-the-current-location-of-an- IFRAME) – sdleihssirhc 2011-05-09 18:49:14