2011-10-31 20 views
4

我有四個環節:空白鏈接在同一窗口中打開 - 爲什麼以及如何解決?

<a href="http://google.com" target="_blank">Google</a> 
<a href="http://bing.com" target="_blank">Bing</a> 
<a href="http://yahoo.com" target="_blank">Yahoo</a> 
<a href="http://wikipedia.com" target="_blank">wiki</a> 

當我點擊一個鏈接,它會在新窗口中打開。 然後點擊另一個鏈接,它會在上次打開的同一個窗口中打開。

這對我來說並不好,我想在每次點擊時打開一個空白窗口,而不管打開的窗口如何。

我該如何處理? (我不在乎雙擊谷歌鏈接打開它兩次,沒關係。)

這是工程,只是它必須。

EXCUSE ME,與我的PHP野獸溝通問題。

所以,實際上鍊接是這樣的:

<a href="javascript:;" onclick = "window.open('http://google.com','Admin');">gaagle</a> 
<a href="javascript:;" onclick = "window.open('http://bing.com','Admin');">bang</a> 
<a href="javascript:;" onclick = "window.open('http://yahoo.com','Admin');">yahuu!</a> 

而現在,所有的東西打開同一窗口,因爲這個名字標籤(window.open的第二個PARAM)-.-並且由於所有打開的窗口ID都是Admin,在該窗口上打開了其他所有窗口。我沒有檢查它,請原諒我浪費你的時間。

+1

不能在FF7,鉻15,或IE8重現 - 它總是打開一個新窗口。你在測試哪個瀏覽器?你確定沒有JavaScript干擾? –

+0

chrome latest,firefox 8.0 –

+1

我沒有看到你描述的內容,你必須以某種方式重現問題。 –

回答

11

如果您爲每個鏈接指定不同的目標,它們將在不同的選項卡/窗口中打開。

<a href="http://google.com" target="googleWindow">Google</a> 
<a href="http://bing.com" target="bingWindow">Bing</a> 
<a href="http://yahoo.com" target="yahooWindow">Yahoo</a> 
<a href="http://wikipedia.com" target="wikiWindow">wiki</a> 

如果您再次單擊某個鏈接,它將重新使用現有窗口(如果它仍然可用)。

如果您使用target="_blank"無論以前的點擊是什麼,每次點擊都應該位於新標籤頁/窗口中。如果你沒有得到這種行爲,你使用什麼瀏覽器?

如果你想獲得的所有點擊,以轉到同一窗口中使用...

<a href="http://google.com" target="myWindow">Google</a> 
<a href="http://bing.com" target="myWindow">Bing</a> 
<a href="http://yahoo.com" target="myWindow">Yahoo</a> 
<a href="http://wikipedia.com" target="myWindow">wiki</a> 
+0

Neet,我不知道這個:)但問題已經通過詢問程序員解決了:有沒有人編輯我的模板? 'O操作。 O操作。 o/o. –

+0

你可能想考慮這個替代方案,因爲它不需要JavaScript。 – Fenton

相關問題