2016-05-31 33 views
0

我試圖實現的是打開彈出窗口的windowopen()函數。同時在主窗口中將用戶轉到另一個頁面。彈出窗口並點擊後重定向

<a href="http://www.google.com/" class="thumbnail" 
    onclick="return !window.open(this.href, 'Google', 'width=500,height=500')" 
    target="_blank"> 
    Link 
</a> 

所以一旦用戶點擊Link我想要的彈出式視窗加載谷歌和原來的頁面給用戶導航到.index.php有什麼建議?

+2

我沒有得到它100% - 你的意思是你想要一個彈出和點擊鏈接後重定向? (就像大多數色情網站?) – messerbill

+0

@messerbill是啊,這是正確的ahaha:3 –

+0

'!window.open(this.href,'Google','width = 500,height = 500')'是不正確的。檢查window.open的文檔! –

回答

1
<a href="http://www.google.com/" class="thumbnail" 
    onclick="window.open(this.href, 'newwindow', 'width=500,height=500'); return true;"> 
    Link 
</a> 
+0

這就是我非常感謝你後!但是有沒有辦法改變一個目的地? –

+0

不錯...歡迎 – Mani

+1

代替this.href使用單引號域名 – Mani

1

下面的代碼在Chrome和Firefox:

<a onClick="window.location='http://www.yahoo.com'" target='_blank' href="http://www.google.com">Click me</a> 

彈出式窗口,大多數瀏覽器自動攔截,因此它可能是最好使用一個href與目標設定爲「_blank」

+1

這正是我非常感謝你的原因。 –

1

通過使用jQuery

$(".link").click(function(){ 
    window.open($(this).attr("href"), "popupWindow", "width=600,height=600,scrollbars=yes"); 
}); 

Demo

相關問題