2

When i click on button to open new window in java script then open new window but in URL automatically append my server name. how to remove this error. code given below.

Html code:

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

java script code:

$('#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

locahost/www.helloexpert.com

why append localhost in start please help me:

1
  • put http:// infront of the url Commented Oct 4, 2013 at 10:28

6 Answers 6

3

Append the protocol specifier http:// to your url.

Sign up to request clarification or add additional context in comments.

2 Comments

this must be a comment!
@Ashish why it should be comment, since that is the correct answer?
2

You should use "http://www.helloexperts.com/index.php?main_page=filerange_chat&ex=1" in the open function

Comments

0

You need to include the protocol (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.

Comments

0

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>

Comments

0

Return not required..

Try this:

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

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

}):

Comments

0

Try this:

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

Comments