如何在以下脚本中添加超时?我希望它将文本显示为"超时".
var bustcachevar = 1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects = ""
var rootdomain = "http://" + window.location.hostname
var bustcacheparameter = ""
function ajaxpage(url, containerid) {
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject) { // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} catch (e) {
try {
page_request = new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {}
}
} …Run Code Online (Sandbox Code Playgroud) 尝试在我的内容和后台脚本之间进行通信时,我收到以下错误:
Port error: Could not establish connection. Receiving end does not exist.
Error in event handler for 'undefined': Cannot read property 'message' of undefined
TypeError: Cannot read property 'message' of undefined
Run Code Online (Sandbox Code Playgroud)
background.js
function onRequest(request, sender, callbackFunction) {
console.log("Me (BS) became this Message:" + request.message);
sendResponse({message: request.message})
};
chrome.extension.onRequest.addListener(onRequest);
Run Code Online (Sandbox Code Playgroud)
streamcloud.js
function contactBackground(nachricht){
chrome.extension.sendMessage({message: nachricht}, function(response) {
console.log("The Background Script got the following Message: " + response.message);
});
}
Run Code Online (Sandbox Code Playgroud)
和我的manifest.json
{
"name": "InstantWatch - Dev",
"manifest_version": 2,
"version": "0.7",
"permissions": ["tabs", …Run Code Online (Sandbox Code Playgroud)