这可能听起来像重复的问题,但我不知道我面临什么问题。无法在浏览器中打开新标签页?
这是我的代码
<!DOCTYPE html>
<html>
<body>
<script>
function open()
{
var win = window.open('http://stackoverflow.com/', '_blank');
if(win){
win.focus();
}else{
alert('Please allow popups for this site');
}
}
</script>
<div align="center">
<h4>Online Users</h4>
<ul>
<li onClick="open()">John</li>
</ul>
</div>
<link href="http://fonts.googleapis.com/css?family=Open+Sans Condensed:300italic,300,700" rel="stylesheet" type="text/css">
<div class="nomessages">
<img src="../img/unnamed.jpg" id="noMessagesImage" />
</div>
<div class="chatscreen">
<ul class="chats">
<!-- The chat messages will go here -->
</ul>
</div>
<form id="chatform">
<textarea id="message" placeholder="Write something.." rows="10" cols="30"></textarea>
<input type="submit" id="submit" value="SEND"/>
</form>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="../js/moment.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="../js/chat.js"></script>
</body>
</html>
我希望能打开当我点击约翰一个新的标签,而是它开在同一window.I的网址不知道我在做什么错在这里
我不那么肯定,但我认为这行为是浏览器控制的 - 我的意思是,何时打开新窗口或新标签页。 – DontVoteMeDown
我正在使用firfox 28.0我在chrome中也面临同样的问题。所以有没有其他的 – Fresher
@ laaposto的答案对我有用。但这是因为我的浏览器设置为在新标签中打开,而不是新窗口。打开某个东西的唯一方法是使用'window.open'。但是,浏览器决定如何打开它。 – DontVoteMeDown