Javascript 未捕获的语法错误:输入意外结束
我在google chrome扩展的javascript控制台中遇到这个错误,我不知道为什么,有人能帮我吗? 以下是我的脚本: popup.jsJavascript 未捕获的语法错误:输入意外结束,javascript,jquery,html,google-chrome-extension,Javascript,Jquery,Html,Google Chrome Extension,我在google chrome扩展的javascript控制台中遇到这个错误,我不知道为什么,有人能帮我吗? 以下是我的脚本: popup.js function urlReduce(href){ href = href.replace(href.substring(href.indexOf(location.pathname), href.length), ""); href = href.replace("http://", "").replace("www.", "");
function urlReduce(href){
href = href.replace(href.substring(href.indexOf(location.pathname), href.length), "");
href = href.replace("http://", "").replace("www.", "");
return href;
}
chrome.runtime.onMessage.addListener(function (message) {
var hosts = ["novamov.com", "videoweed.es", "vidspot.net", "allmyvideos.net", "streamcloud.eu", "magnovideo.com", "played.to", "vk.com", "moevideos.net", "youtube.com", "videomega.tv", "movshare.net"];
var url = urlReduce(message.url);
var found = $.inArray(url, hosts) > -1;
if (found) {
alert("sending msg");
chrome.runtime.sendMessage({method:'getInfo'}, function(response){
var response_array = response.split(",");
var title = response_array[0];
var serie = response_array[1];
var number = response_array[2];
var url = response_array[3];
});
$("#serie").html(serie);
$("#url").html(url);
$("#number").html(number);
$("#title").html(title);
}
}
这里是popup.html中的标题
<head>
<script src="jquery.min.js"></script>
<script src="popup.js"></script>
</head>
第二个函数有回调,未正确关闭
function urlReduce(href) {
href = href.replace(href.substring(href.indexOf(location.pathname), href.length), "");
href = href.replace("http://", "").replace("www.", "");
return href;
}
chrome.runtime.onMessage.addListener(function (message) {
var hosts = ["novamov.com", "videoweed.es", "vidspot.net", "allmyvideos.net", "streamcloud.eu", "magnovideo.com", "played.to", "vk.com", "moevideos.net", "youtube.com", "videomega.tv", "movshare.net"];
var url = urlReduce(message.url);
var found = $.inArray(url, hosts) > -1;
if (found) {
alert("sending msg");
chrome.runtime.sendMessage({
method: 'getInfo'
}, function (response) {
var response_array = response.split(",");
var title = response_array[0];
var serie = response_array[1];
var number = response_array[2];
var url = response_array[3];
});
$("#serie").html(serie);
$("#url").html(url);
$("#number").html(number);
$("#title").html(title);
}
}); // close it properly
浏览器控制台应该告诉你错误在哪里,至少我的是这样