猿问

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

我这需要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;

}

}


Yeah___
浏览 1826回答 3
3回答

慕运维7130634

<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <script> var newPage; if(newPage!=""){ alert(1)//不报错 } </script> </body></html>

慕运维7130634

你叫我怎么帮你?

慕运维7130634

上代码
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答