我正在尝试使用Chrome的API获取当前选项卡的图标,并通过请求发送它:
function sendRequest(update, tab){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText);
}
};
icon = "";
url = "";
if (tab.status == 'complete')
icon = tab.favIconUrl;
url = tab.url;
formD = new FormData();
formD.append("url", url);
formD.append("ic_link", icon);
xhttp.open("POST", "Python_server####/send_url");
xhttp.send(formD);
}
但是,favicon URL始终为空或未定义。我还尝试直接使用document.getElementById("shortcut icon").href
访问链接,但我不确定这是否合法。有什么想法吗
tab.favIconUrl属性仅在扩展具有tabs或activeTab权限时可用。如果选项卡处于加载状态,则它也是空字符串“”
相关问题 更多 >
编程相关推荐