2013-03-23 54 views
0

我有一個頁面,是這樣的:在網頁的HTML如何將散列值從頁面傳遞到iframe?

http://mypage.com/about#peter 

我有一個iframe:

<iframe src="doit" /> 

我想#peter去iframe中。也就是說,我希望iframe呈現爲

<iframe src="doit#peter /> 

關於top如何實現的提示?

感謝

+0

我已經嘗試了第一行,希望html能夠足夠聰明地將哈希標記傳遞給iframe。 – 2013-03-23 17:04:14

回答

2

您可以以編程方式創建的iframe當頁面運行和散列標籤附加到它。

var hash = window.location.hash; 
var ifrm = document.createElement("IFRAME"); 
ifrm.setAttribute("src", "http://mypage.com/about" + hash); 
document.body.appendChild(ifrm); 
相關問題