2
步驟來重現問題端口錯誤:無法建立連接。接收端不存在
一)具有以下
B中的所有代碼編寫的擴展)轉到https://stackoverflow.com/
c)單擊「熱門問題:標題
您會收到一條錯誤消息,說「端口錯誤:無法建立連接。接收端不存在」
清單文件
{
"name": "Demo",
"version": "1.0",
"manifest_version": 2,
"description": "This is a demo",
"content_scripts": [ {
"all_frames": true,
"js": ["contentscript1.js" ],
"matches": [ "https://stackoverflow.com/" ]
}]
}
Editor.html文件
<html>
<head>
<script src="editor.js"></script>
</head>
<body>
<div id="content"></div>
</body>
</html>
editor.js內文件個
function onRequest(message,sender,call){
document.getElementById("content").value = message;
}
chrome.extension.onMessage.addListener(onRequest);
contentscript1.js
function bindevent(){
window.open(chrome.extension.getURL("editor.html"),"_blank","toolbar=no, titlebar=no,location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=yes, width=720, height=400");
message = "Sample Message";
chrome.extension.sendMessage(message,function (res){});
};
document.getElementById('h-top-questions').onclick=bindevent;
任何建議?
什麼是「不是default_popup html文件的HTML頁面」? –
此HTML頁面包含'code''code'且span是內容的接收者;通過窗口打開此頁面的更多內容。打開()點擊的圖標也注入DOM – Sudarshan
我的.crx中有2個html文件1)瀏覽器操作圖標被點擊時打開的文件2)我所指的文件 – Sudarshan