ActiveX Errors in JavaScript

I've made a link in JavaScript which open MS Excel & loads the requested file in it. On clicking the link, an option appears asking "An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?"

If I click YES, the MS Excel opens & the file is loaded successfully. But If I click NO, the page returns with an "ERROR LOADING THE PAGE". It should not return this error. The code is as

<head>
<script language="JavaScript">
     function startXL(str)
     {
          var app = new ActiveXObject("Excel.Application");
          if(app!=null){
               app.visible = true;
               if(str=="0"){
                    app.workbooks.open("file:///c:/MIS/Reports/Qatar/ABA/2005/2005-ABA-ANALYSIS.xls");
               }else
               if(str=="1"){
                    app.workbooks.open("file:///c:/MIS/Reports/Qatar/ABA/2006/2006-ABA-ANALYSIS.xls");
               }
          }
          return false;
     }
</script>
</head>

<body>
<a href="#" onClick="startXL(0);return false;" style="font-family:arial;color:darkgreen;font-size:12px;text-decoration:none;">ABA Report 2005</a>
<br><a href="#" onClick="startXL(1);return false;" style="font-family:arial;color:darkgreen;font-size:12px;text-decoration:none;">ABA Report 2006</a>
</body>
adnan_raisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bubbledragonCommented:
Try below:
<script language="JavaScript">
window.onerror=new Function ('return true;');
</script>
0
adnan_raisAuthor Commented:
ok fine on clicking NO, the page doesn't return any error but the URL becomes like this "file:///C:/MIS/QatarMIS.html#" & when I click on some other link, no response occurs. WHY?
0
adnan_raisAuthor Commented:
I think there's some problem with the "#" sign placed in the URL
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

adnan_raisAuthor Commented:
I've to refresh the page every time to continue functioning
0
adnan_raisAuthor Commented:
any idea bubbledragon?
0
bubbledragonCommented:
ActiveX alert ask for once, if click no, all will not run until you refresh the page.
0
adnan_raisAuthor Commented:
Tell me another appropriate solution b'coz ofcourse the Web Users r not going 2 refresh the page after first ActiveX alert, if I do use ur code
0
adnan_raisAuthor Commented:
Tell me another appropriate solution b'coz ofcourse the Web Users r not going 2 refresh the page after first ActiveX alert, if I do use ur code
0
smaccariCommented:
Unfortunately, if the user clicked NO, the browser will not enable your activeX to start until the user refreshes the page (and then will be asked again for enabling activeX execution).

The better way then would be to prevent prompting when an activeX is used on your page.
But this can be a security issue though, and that means that you can change the browser's configuration of all your users.

Is your page opened (by your users) through a web server (local or internet) or simply on a local file system ?

If opened on a web server and if you can change the browsers config, simply add the domain of your server in the Trusted Sites list, this should work then better (if not, just check the security level for trusted site and select the right otion for your activex)

If opened locally, through a file system, there is a trick you can use on IE.
In your source code, add a line before the <HTML> tag like this :

<!-- saved from url=(0025)http://www.domainname.com -->

By doing this, IE will act (for security purposes) just like your web page is on the domain written in this line (in this case, www.domainname.com). All you have to do then is to add this domain on the trusted sites, and it should work.
Simply put a domain your are sure doesn't exist (still for security reasons).
The numbers in the code are just the length of the url (including http://).

Hope this will help.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
adnan_raisAuthor Commented:
Thanx smaccari, u r really a very smart EXPERT ;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.