function text()
{
var i = "";
var WshNetwork = new ActiveXObject("aa") ; // return WshNetwork.UserName;
i=WshNetwork.UserName;
return i
}
“var WshNetwork = new ActiveXObject("aa") ;”这句肯定会报错,怎么忽视报错让text()方法继续运行从而得到test()方法的返回值i="", 从而为接下来的函数调用返回值,因为下一个函数一定要调用text()返回值才能运行,为用也可以。
17 个解决方案
#1
function text()
{
var i = "";
try
{
var WshNetwork = new ActiveXObject("aa") ; // return WshNetwork.UserName;
}
catch(ex)
{
}
i=WshNetwork.UserName;
return i
}
{
var i = "";
try
{
var WshNetwork = new ActiveXObject("aa") ; // return WshNetwork.UserName;
}
catch(ex)
{
}
i=WshNetwork.UserName;
return i
}
#2
加一个window.onerror = function(){
return true;
}
return true;
}
#3
顶!!
#4
在哪家,怎么加啊,window.onerror, 在哪调用呢
#5
源代码如下
function text()
{
var i = "";
//var WshNetwork = new ActiveXObject("WScript.Network");
var WshNetwork = new ActiveXObject("aa") ;
// return WshNetwork.UserName;
i=WshNetwork.UserName;
return i
}
function text()
{
var i = "";
//var WshNetwork = new ActiveXObject("WScript.Network");
var WshNetwork = new ActiveXObject("aa") ;
// return WshNetwork.UserName;
i=WshNetwork.UserName;
return i
}
#6
有两种方式可以处理,一是楼上诸位讲的window.onerror:
window.onerror = function(){return true;};
另外一种就是try{}catch(e){}
window.onerror = function(){return true;};
另外一种就是try{}catch(e){}
#7
function text()
{
var i = "";
var WshNetwork = new ActiveXObject("aa") ;
i=WshNetwork.UserName;
return i
}
window.onload=function()
{
alert(text());
document.getElementById("name").value=text();
var s = document.getElementById("name").value;
if(s==""){
document.location.href="err.html";
}
else{
document.getElementById("tab1").style.display="";
}
}
“var WshNetwork = new ActiveXObject("aa") ;”报错后就运行不了打开页面函数“function()" ,if else 语句执行不了。
{
var i = "";
var WshNetwork = new ActiveXObject("aa") ;
i=WshNetwork.UserName;
return i
}
window.onload=function()
{
alert(text());
document.getElementById("name").value=text();
var s = document.getElementById("name").value;
if(s==""){
document.location.href="err.html";
}
else{
document.getElementById("tab1").style.display="";
}
}
“var WshNetwork = new ActiveXObject("aa") ;”报错后就运行不了打开页面函数“function()" ,if else 语句执行不了。
#8
重定向window.onerror不好,这样所有的JS错误就都不显示了,还是try catch吧
#9
try catch 怎么加,放哪能够正常运行function()
#10
function text()
{
var i = "";
try{
var WshNetwork = new ActiveXObject("aa") ; // return WshNetwork.UserName;
i=WshNetwork.UserName;
}
catch(e){
}
return i
}
{
var i = "";
try{
var WshNetwork = new ActiveXObject("aa") ; // return WshNetwork.UserName;
i=WshNetwork.UserName;
}
catch(e){
}
return i
}
#11
try{}catch(e){} 这种最省事了。
#12
window.onerror = function(){
return true;
}这个东西我怎么都没有效果的.
return true;
}这个东西我怎么都没有效果的.
#13
<script type="text/javascript">
window.onerror=testError;
function testError(){
arglen=arguments.length;
var errorMsg="参数个数:"+arglen+"个";
for(var i=0;i<arglen;i++){
errorMsg+="\n参数"+(i+1)+":"+arguments[i];
}
alert(errorMsg);
window.onerror=null;
return true;
}
function test(){
error
}
test()
</script>
#14
还是用try{}catch(){}方便
#15
try catch 你别忘了处理啊,我以前的同事到处try又不处理留下一堆垃圾
#16
一是楼上诸位讲的window.onerror:
window.onerror = function(){return true;};
另外一种就是try{}catch(e){}
window.onerror = function(){return true;};
另外一种就是try{}catch(e){}
#17
window.onerror:
try{}catch(e){}
try{}catch(e){}
#1
function text()
{
var i = "";
try
{
var WshNetwork = new ActiveXObject("aa") ; // return WshNetwork.UserName;
}
catch(ex)
{
}
i=WshNetwork.UserName;
return i
}
{
var i = "";
try
{
var WshNetwork = new ActiveXObject("aa") ; // return WshNetwork.UserName;
}
catch(ex)
{
}
i=WshNetwork.UserName;
return i
}
#2
加一个window.onerror = function(){
return true;
}
return true;
}
#3
顶!!
#4
在哪家,怎么加啊,window.onerror, 在哪调用呢
#5
源代码如下
function text()
{
var i = "";
//var WshNetwork = new ActiveXObject("WScript.Network");
var WshNetwork = new ActiveXObject("aa") ;
// return WshNetwork.UserName;
i=WshNetwork.UserName;
return i
}
function text()
{
var i = "";
//var WshNetwork = new ActiveXObject("WScript.Network");
var WshNetwork = new ActiveXObject("aa") ;
// return WshNetwork.UserName;
i=WshNetwork.UserName;
return i
}
#6
有两种方式可以处理,一是楼上诸位讲的window.onerror:
window.onerror = function(){return true;};
另外一种就是try{}catch(e){}
window.onerror = function(){return true;};
另外一种就是try{}catch(e){}
#7
function text()
{
var i = "";
var WshNetwork = new ActiveXObject("aa") ;
i=WshNetwork.UserName;
return i
}
window.onload=function()
{
alert(text());
document.getElementById("name").value=text();
var s = document.getElementById("name").value;
if(s==""){
document.location.href="err.html";
}
else{
document.getElementById("tab1").style.display="";
}
}
“var WshNetwork = new ActiveXObject("aa") ;”报错后就运行不了打开页面函数“function()" ,if else 语句执行不了。
{
var i = "";
var WshNetwork = new ActiveXObject("aa") ;
i=WshNetwork.UserName;
return i
}
window.onload=function()
{
alert(text());
document.getElementById("name").value=text();
var s = document.getElementById("name").value;
if(s==""){
document.location.href="err.html";
}
else{
document.getElementById("tab1").style.display="";
}
}
“var WshNetwork = new ActiveXObject("aa") ;”报错后就运行不了打开页面函数“function()" ,if else 语句执行不了。
#8
重定向window.onerror不好,这样所有的JS错误就都不显示了,还是try catch吧
#9
try catch 怎么加,放哪能够正常运行function()
#10
function text()
{
var i = "";
try{
var WshNetwork = new ActiveXObject("aa") ; // return WshNetwork.UserName;
i=WshNetwork.UserName;
}
catch(e){
}
return i
}
{
var i = "";
try{
var WshNetwork = new ActiveXObject("aa") ; // return WshNetwork.UserName;
i=WshNetwork.UserName;
}
catch(e){
}
return i
}
#11
try{}catch(e){} 这种最省事了。
#12
window.onerror = function(){
return true;
}这个东西我怎么都没有效果的.
return true;
}这个东西我怎么都没有效果的.
#13
<script type="text/javascript">
window.onerror=testError;
function testError(){
arglen=arguments.length;
var errorMsg="参数个数:"+arglen+"个";
for(var i=0;i<arglen;i++){
errorMsg+="\n参数"+(i+1)+":"+arguments[i];
}
alert(errorMsg);
window.onerror=null;
return true;
}
function test(){
error
}
test()
</script>
#14
还是用try{}catch(){}方便
#15
try catch 你别忘了处理啊,我以前的同事到处try又不处理留下一堆垃圾
#16
一是楼上诸位讲的window.onerror:
window.onerror = function(){return true;};
另外一种就是try{}catch(e){}
window.onerror = function(){return true;};
另外一种就是try{}catch(e){}
#17
window.onerror:
try{}catch(e){}
try{}catch(e){}