Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 601
  • Last Modified:

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>
0
adnan_rais
Asked:
adnan_rais
  • 7
  • 2
1 Solution
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
adnan_raisAuthor Commented:
Thanx smaccari, u r really a very smart EXPERT ;-)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now