如何在javascript中点击按钮打开新窗口

时间:2013-10-04 10:26:45

标签: javascript php html

当我点击按钮在java脚本中打开新窗口然后打开新窗口但在URL中自动附加我的服务器名称。如何删除此错误。代码如下。

Html代码:

<input class="cssButton button_buy_now" type="submit" name="live_chat" id="live_chat" value="Get Answer"></input>

java脚本代码:

$('#live_chat').click(function() {
    return window.open("www.helloexperts.com/index.php?main_page=filerange_chat&ex=1");
}):

但是当新窗口打开时会自动将localhost添加到

开头
locahost/www.helloexpert.com

为什么在开始时追加localhost请帮助我:

6 个答案:

答案 0 :(得分:3)

将协议说明符http://附加到您的网址。

答案 1 :(得分:2)

答案 2 :(得分:0)

您需要包含协议(http://)。

$('#live_chat').click(function() {

return window.open("http://www.helloexperts.com/index.php?main_page=filerange_chat&ex=1");
// Change ----------^^^^^^^

}):

否则,它是一个相对链接。

答案 3 :(得分:0)

试试这个

<html>
<head>
<script>
function open_win() 
{
window.open("url");
}
</script>
</head>

<body>
<form>
<input type="button" value="Open Window" onclick="open_win()">
</form>
</body>

</html>

答案 4 :(得分:0)

不需要退货..

试试这个:

$('#live_chat').click(function() {

window.open('sample.html','_blank','width=200,height=300');

}):

答案 5 :(得分:0)

试试这个:

$('#live_chat').click(function() {
    window.location.href="www.helloexperts.com/index.php?main_page=filerange_chat&ex=1";
});
相关问题