您的位置:首页 > 其它

chrome 插件学习

2016-03-10 15:42 351 查看
直接在 background.js
getPrice(); //直接运行

function handleError() {

}

function getPrice(){
var xhr = new XMLHttpRequest();

xhr.onreadystatechange = function() {
if (xhr.readyState == 4){
if(xhr.status==200){
//表示服务器端的响应代码是200,正确的返回了数据
//纯文本数据的接受方法
//var message=xmlhttp.responseText;
console.log(xhr.responseText);
}
}

};

xhr.open("GET", "http://demo.com", true);
xhr.send(null);
//console.error(xhr.response);
}

chrome.browserAction.setBadgeText({text:"1234"}); //插件icon添加文字

定时
var priceInterval = window.setInterval(function() {
self.getPrice();}, 30000);
}



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: