Detect ActiveX

  • Thread starter Thread starter David C
  • Start date Start date
D

David C

I have an ASP.Net page that displays documents as hyperlinks from a network
folder (intranet application). I also have a column that contains a
hyperlink to open the document in Microsoft Word. All works fine unless
someone has ActiveX disabled on their browser. Is there any way I can
detect that so I can give them a warning?

The script for opening a Word document is below. Thanks.

-David

<script language="javascript" type="text/javascript">

function openWord(spath)
{
var pause = 0;
var wdDialogFileOpen = 80;
var wdApp = new ActiveXObject("Word.Application");
wdApp.Visible = 'True';
var wdDoc = wdApp.Documents;
wdDoc.Open(spath);
document.form1.submit();
}

</script>
 
I have an ASP.Net page that displays documents as hyperlinks from a network
folder (intranet application). I also have a column that contains a
hyperlink to open the document in Microsoft Word.  All works fine unless
someone has ActiveX disabled on their browser.  Is there any way I can
detect that so I can give them a warning?

The script for opening a Word document is below.  Thanks.

-David

<script language="javascript" type="text/javascript">

function openWord(spath)
{
    var pause = 0;
    var wdDialogFileOpen = 80;
    var wdApp = new ActiveXObject("Word.Application");
    wdApp.Visible = 'True';
    var wdDoc = wdApp.Documents;
    wdDoc.Open(spath);
    document.form1.submit();

}

</script>

Hi David,

I think you can simply add the try..catch block to check the result of
ActiveXObject

try {

var wdApp = new ActiveXObject("Word.Application");
wdApp.Visible = 'True';
var wdDoc = wdApp.Documents;
wdDoc.Open(spath);
document.form1.submit();

} catch (er) {

alert('You have no Word ActiveX');

}
 
Back
Top