這個代碼為什么會還沒按按鈕就自動跳轉到url網址?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>無標題文檔</title>
</head>
<body>
<script type="text/javascript">
var main = document.body;
//創建鏈接
function jump(url){
? ? window.open(url);
}
function createa(url,text)
{
? ? var input=document.createElement("input");
? ? input.type="button";
? ? input.value=text;
? ? input.setAttribute("onclick",jump(url));
? ? main.appendChild(input);
}
// 調用函數創建鏈接
createa('http://www.xianlaiwan.cn','慕課網');
</script>?
</body>
</html>
2020-04-09
?input.setAttribute("onclick",jump(url));? ?jump 函數里面有 window,open(),你把這個去掉