2016-02-20 38 views
-2

我有一個PHP/HTML按鈕誰是鏈接到的OnClick按鈕不轉發到URL

<a href="#" data-mini="true" data-role="button" onClick="window.open('../index.php', '_self');"><? echo "Login"; ?></a> 

現在我想切換到其他鏈接網址www.button.com/index.html我改變了國家統計局爲:

<a href="#" data-mini="true" data-role="button" onClick="window.open('www.button.com/index.html', '_self');"><? echo "Login"; ?></a> 

第二個URL位於其他文件夾中的同一臺服務器上,但點擊按鈕不轉發即可鏈接。

+0

諸如'www'的外部URL調用需要'http://',即使它位於同一臺服務器上。您現在可以刪除該問題。 –

回答

0

如果您未指定協議(例如http),則該功能假定您想要轉到同一個域的頁面。 嘗試是這樣的:

<a href="#" data-mini="true" data-role="button" onclick="window.open('http://www.button.com/index.html', '_self');"><?="Login" ?></a> 

而且,你爲什麼要使用JavaScript事件?只需將URL放在href屬性(href="//www.button.com")中即可簡化此操作。

+0

[*是的,我說了15分鐘。在此之前... *](http://stackoverflow.com/questions/35518442/onclick-button-not-forward-to-url#comment58727268_35518442) - 也許他們會回答你,而不是評論。 –

+0

解決了問題 – Vitali