今天我正在尝试用javascript / jQuery来做这件事;发生错误时,此错误例如
Refused to display 'http://example.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN, SAMEORIGIN'.
该脚本将运行一个函数将它们重定向到他们去往的网站。
答案 0 :(得分:1)
你可以这样做:
try{
//some bug
}
catch(ex){
if(ex=="Some Error Message"){
//do something here
}
}
答案 1 :(得分:1)
使用try / catch
try {
//some code to do
} catch(exc){
if(exc == "Refused to display 'http://example.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN, SAMEORIGIN'."){
//your redirect code here
}
}
如果错误是其他错误,只需用错误替换Refused to display 'http://example.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN, SAMEORIGIN'.