简体   繁体   English

如何在Java脚本中单击按钮中的打开新窗口

[英]How to open new window on button in click in java script

When i click on button to open new window in java script then open new window but in URL automatically append my server name. 当我单击按钮以Java脚本打开新窗口,然后打开新窗口,但在URL中自动附加我的服务器名称。 how to remove this error. 如何清除此错误。 code given below. 下面给出的代码。

Html code: HTML代码:

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

java script code: Java脚本代码:

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

but when new window open automatically append localhost in start like 但是当新窗口打开时自动将localhost附加在开始中

locahost/www.helloexpert.com

why append localhost in start please help me: 为什么在启动时附加本地主机,请帮助我:

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

You need to include the protocol ( http:// ). 您需要包括协议( http:// )。

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

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

}):

Otherwise, it's a relative link. 否则,这是一个相对链接。

Try like this 这样尝试

<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>

Return not required.. 不需要退货。

Try this: 尝试这个:

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

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

}):

Try this: 尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM