Link to home
Start Free TrialLog in
Avatar of JimV_ATL
JimV_ATL

asked on

Soft Failure for saying No to Active X warning or if Disabled in Security.

The following script works fine for me:

<html>
<head>
<title></title>
<script>
onload = function() {
var objXL = new ActiveXObject("Excel.Application")
alert(objXL.version)
objXL.Quit()
}
</script>
</head>
<body>
</body>
</html>

Say someone returns "no" to an active x security prompt or activex is disallowed entirely, I would like the above script to have a soft failure...i.e. alert('Failed');

How might I do that?
ASKER CERTIFIED SOLUTION
Avatar of gph
gph

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JimV_ATL
JimV_ATL

ASKER

I wasn't aware that Javascript had error handling.  This works fine (in I.E. >= 5, at least).

<html>
<head>
<title></title>
<script>
function function1() {
     try {
          var objXL = new ActiveXObject("Excel.Application");
          myversion = objXL.version;
          objXL.Quit();
     } catch(err) {
          myversion = 0;
     } finally {
         
        alert(myversion);
     }
}
</script>
</head>
<body onload="function1();">
</body>
</html>
GPH's is not the answer I was looking for, however, as he made the effort to repond, I'm awarding him the points.

See my comment above for the answer.
Cool, I didn't think that would work.

<html>
<head>
<title></title>
<script>
IE5 = (document.all && document.getElementById)?true:false;

function function1() {
  if (IE5) {
    try {
         var objXL = new ActiveXObject("Excel.Application");
         myversion = objXL.version;
         objXL.Quit();
    } catch(err) {
         myversion = 0;
    } finally {
         
       alert(myversion);
    }
  }
}
</script>
</head>
<body onload="function1();">
</body>
</html>

I don't want any points for that because you found the answer
to late :) thatnk you