javascript - window.open() 使用用户输入作为 url 源在 Chrome 中打开选项卡而不是窗口
问题描述
无论我尝试什么,此代码仍会在新选项卡中打开。关于如何修改它以打开新窗口的任何想法?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Cast Challonge</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#button').click(function(e) {
var inputvalue = $("#input").val();
window.open("http://challonge.com/"+inputvalue+"/module?theme=5928&show_final_results=0&multiplier=0.3&show_tournament_name=1&scale_to_fit=1"),"_blank","width=1323,height=816";
});
});
</script>
</head>
<body>
<input type="text" value="" id="input">
<button type="button" id="button">Submit Tournament ID</button>
</body>
</html>
解决方案
分享正确答案以防有人需要:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Cast Challonge</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#button').click(function(e) {
var inputvalue = $("#input").val();
window.open(("http://challonge.com/"+inputvalue+"/module?theme=5928&show_final_results=0&multiplier=0.3&show_tournament_name=1&scale_to_fit=1"),"_blank","width=1323,height=816";)
});
});
</script>
</head>
<body>
<input type="text" value="" id="input">
<button type="button" id="button">Submit Tournament ID</button>
</body>
</html>
推荐阅读
- c# - 如何反序列化动态 Json 对象?
- pandas - 输入必须是数组、列表、元组或标量 pyproj
- python - Django 项目模板不存在
- c# - 具有自定义颜色的 DataTrigger
- python - Python 在 xml 中搜索
- python - 如何让 crypt 模块仅在参数值与给定值相同时工作?
- reactjs - 反应错误:无法读取未定义的属性“地图”
- powershell - 如何从 Windows 命令提示符调用提升的 PowerShell 来执行命令和 PowerShell 脚本文件?
- javascript - 为什么排序不适用于某些列?
- php - 我应该将 OPcache 用于简单的 PHP 网站吗