捕捉浏览器中的JS运行时错误,主要通过监听window.onerror来实现。但是对于不同的脚本执行方式以及不同的浏览器,能捕获到的信息会有区别。
window.onerror 讲接收3个参数:
msg
:错误描述,比如:a is not definedurl
:出错脚本所在的urllineNumber
:出错脚本的行数
本文将对不同浏览器和不同的脚本执行方式进行测试,并总结这些区别。
function exceptionalException(message) { | |
'use strict'; | |
if (exceptionalException.emailErrors !== false) { | |
exceptionalException.emailErrors = confirm('We had an error reporting an error! Please email us so we can fix it?'); | |
} | |
} | |
//test | |
//exceptionalException('try 1!'); | |
//exceptionalException('try 2!'); |
捕捉浏览器中的JS运行时错误,主要通过监听window.onerror来实现。但是对于不同的脚本执行方式以及不同的浏览器,能捕获到的信息会有区别。
window.onerror 讲接收3个参数:
msg
:错误描述,比如:a is not definedurl
:出错脚本所在的urllineNumber
:出错脚本的行数本文将对不同浏览器和不同的脚本执行方式进行测试,并总结这些区别。
TraceKit.report.subscribe(function(stackInfo) { ... })
TraceKit.report.unsubscribe(function(stackInfo) { ... })
TraceKit.report(exception)
(e.g. try { ...code... } catch(ex) { TraceKit.report(ex); }
)TraceKit will attempt to fetch an analyze source files, but you can turn this off using:
TraceKit.remoteFetching = false;
# | |
# Slightly tighter CORS config for nginx | |
# | |
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs | |
# | |
# Despite the W3C guidance suggesting that a list of origins can be passed as part of | |
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox) | |
# don't seem to play nicely with this. | |
# |
ex () { | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xjf $1 ;; | |
*.tar.gz) tar xzf $1 ;; | |
*.bz2) bunzip2 $1 ;; | |
*.rar) rar x $1 ;; | |
*.gz) gunzip $1 ;; | |
*.tar) tar xf $1 ;; | |
*.tbz2) tar xjf $1 ;; |
<!-- standard viewport tag to set the viewport to the device's width | |
, Android 2.3 devices need this so 100% width works properly and | |
doesn't allow children to blow up the viewport width--> | |
<meta name="viewport" id="vp" content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width" /> | |
<!-- width=device-width causes the iPhone 5 to letterbox the app, so | |
we want to exclude it for iPhone 5 to allow full screen apps --> | |
<meta name="viewport" id="vp" content="initial-scale=1.0,user-scalable=no,maximum-scale=1" media="(device-height: 568px)" /> | |
<!-- provide the splash screens for iPhone 5 and previous --> | |
<link href="assets/splashs/splash_1096.png" rel="apple-touch-startup-image" media="(device-height: 568px)"> | |
<link href="assets/splashs/splash_iphone_2x.png" rel="apple-touch-startup-image" sizes="640x960" media="(device-height: 480px)"> |
// EDIT: 2013/10/20 | |
// google has updated its kwt UI, this script doesn't work any more! | |
// may be I will update this script when I have time to investigate their new Interface. | |
// requires | |
var utils = require('utils'); | |
var casper = require('casper').create() | |
var casper = require('casper').create({ | |
verbose: true, |
# EDIT: 2013/10/20 | |
# google has updated its kwt UI, this script doesn't work any more! | |
# may be I will update this script when I have time to investigate their new Interface. | |
from selenium import webdriver | |
from selenium.common.exceptions import TimeoutException | |
import selenium.webdriver.support.wait | |
selenium.webdriver.support.wait.POLL_FREQUENCY = 0.05 | |
import re |
<!DOCTYPE html> | |
<!-- #include "inc_header.html" title="Example" header="Sample Title" --> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Example</title> | |
<link rel="stylesheet" href="css/main.css"> | |
</head> | |
<body> | |
<h1>Sample Title</h1> |
var system = require('system'); | |
if (system.args.length < 5) { | |
console.info("You need to pass in account name, username, password, and path to casperJS as arguments to this code."); | |
phantom.exit(); | |
} | |
var account = system.args[1]; | |
var username = system.args[2]; | |
var password = system.args[3]; |