![](/img/trans.png)
[英]Is it possible in JS to detect whether any JS was run from the browser's console?
[英]JS/jQuery: Is it possible to extract content from the browser's console?
當我執行console.log(info)
時,以后是否可以使用JS從瀏覽器控制台中提取所有內容並將其添加到var
? 我想提取控制台的所有內容,然后通過AJAX將其發送到服務器
基本上我正在尋找類似的東西:
var console_content = console.read();
JS或jQuery中有什么可以實現這一目標?
而不是寫到控制台(在生產環境中實際上不應該這樣做),為什么不只是將要記錄的每件事都推送到數組,然后在需要時將其通過PUT傳遞到服務器?:
var _log = [];
//instead of console.log(message)
_log.push({message:'message goes here'});
//using jquery because it's easier
function pushAjax(url, data, callback, method) {
return jQuery.ajax({
url: url,
type: method,
data: data,
success: callback
});
}
//call your push function when you want...
pushAjax('www.yourserver.com',_log,'PUT',successFunction);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.