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