为了账号安全,请及时绑定邮箱和手机立即绑定

怎么让if(newPage ! = "")不报错

怎么让if(newPage ! = "")不报错

Yeah___ 2018-01-06 17:21:35
我这需要newPage不等于空,要怎么改啊,大神们Uncaught SyntaxError: Unexpected token !报这个错误window.onload = initForm;window.onunload = function(){};function initForm(){ document.getElementById("newLocation").selectedIndex = 0; document.getElementById("newLocation").onchange = jumppage;}function jumppage(){ var newLoc = document.getElementById("newLocation"); var newPage = newLoc.option[newLoc.selectedIndex].value; if(newPage ! = ''){ window.location = newPage; }}
查看完整描述

3 回答

已采纳
?
慕运维7130634

TA贡献41条经验 获得超18个赞

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

</head>

<body>

<script>

var newPage;

if(newPage!=""){

alert(1)//不报错

}

</script>

</body>

</html>


查看完整回答
反对 回复 2018-01-06
?
慕运维7130634

TA贡献41条经验 获得超18个赞

//img1.sycdn.imooc.com//5a50a80d000105fe06890652.jpg你叫我怎么帮你?

查看完整回答
反对 回复 2018-01-06
?
慕运维7130634

TA贡献41条经验 获得超18个赞

上代码

查看完整回答
反对 回复 2018-01-06
  • Yeah___
    Yeah___
    window.onload = initForm; window.onunload = function(){}; function initForm(){ document.getElementById("newLocation").selectedIndex = 0; document.getElementById("newLocation").onchange = jumppage; } function jumppage(){ var newLoc = document.getElementById("newLocation"); var newPage = newLoc.option[newLoc.selectedIndex].value; if(newPage ! = ''){ window.location = newPage; } }
  • 3 回答
  • 0 关注
  • 1825 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信