我有以下代码:
var first="";
var run=function(){
first = document.getElementById("textbox1").value;
if(first.substring(0,6)==="http://"){
first=first.substring(7,first.length-1);
}
if (first.substring(0, 1) !== " " &&
first !== "unrequired" &&
first.substring(0, 7) !== "http://" &&
first.substring(0, 8) !== "https://" &&
first !== undefined &&
first !== "" &&
first.substring(0, 9) !== "chrome://" &&
first.substring(0, 12) !== "view-source:" &&
first.substring(0, 8) !== "file:///") {
first="http://"+first;
}
if(first===""||first==="unrequired"){
first=undefined;
}
if (first.substring(0,1)===" "){
first="https://www.google.com/search?q=" + first.substring(1,first.length);
}
chrome.tabs.create({url:first})
};
setInterval(run,1);
但是chrome.tabs.create只有在我将其移到函数外部并且不运行该函数时才会运行。显然,函数对变量做了一些事情,但是什么呢?我甚至用警告告诉我出了什么问题