473,395 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Calling VBScript from JavaScript

Hi guys

I am writing a Javascript routine to check for the presence and version of
an Adobe Acrobat PDFViewer on the user's machine. No problem with any
browser on the Mac, no problem with any browser on Windows - except MSIE.

However, I can write a routine in VBScript to cover the MSIE requirement. So
that's cool.

Both the js and vb elements work fine. So I have no problem with core
functionality.

Naturally, my js and vb scripts are in different files and I reference each
of these in the <head> of the HTML document that contains the js function
that makes the initial call.

The initial call is made to a js routine called "checkPDFViewer()". This
calls another js routine called "getAcrobatVersionJS()". This first of all
checks the platform and if it is not one that it knows about, it simply
returns -1. This result is the cue for "checkPDFViewer()" to call the vb
routine "getAcrobatVersionVB()".

Thus...

function checkPDFViewer () {
acrobatVersion = getAcrobatVersionJS();

if (acrobatVersion > -1) {
return true;
}
else {
acrobatVersion = getAcrobatVersionVB();

if (acrobatVersion > -1) {
return true;
}
else {
return false;
}
}
}

The problem is that I get an unknown object being thrown at me by MSIE.

What am I doing wrong? Like I say, individually the various code elements do
what they are supposed to do. I can run them in test harness HTML and they
return the results I expect. The problems arise when I try and work them
together.
Many thanks in advance

Ian

Jul 23 '05 #1
4 10886
Ian Sedwell wrote:
Hi guys

I am writing a Javascript routine to check for the presence and version of
an Adobe Acrobat PDFViewer on the user's machine. No problem with any
browser on the Mac, no problem with any browser on Windows - except MSIE.

However, I can write a routine in VBScript to cover the MSIE requirement. So
that's cool.

Both the js and vb elements work fine. So I have no problem with core
functionality.

Naturally, my js and vb scripts are in different files and I reference each
of these in the <head> of the HTML document that contains the js function
that makes the initial call.

The initial call is made to a js routine called "checkPDFViewer()". This
calls another js routine called "getAcrobatVersionJS()". This first of all
checks the platform and if it is not one that it knows about, it simply
returns -1. This result is the cue for "checkPDFViewer()" to call the vb
routine "getAcrobatVersionVB()".

Thus...

function checkPDFViewer () {
acrobatVersion = getAcrobatVersionJS();

if (acrobatVersion > -1) {
return true;
}
else {
acrobatVersion = getAcrobatVersionVB();

if (acrobatVersion > -1) {
return true;
}
else {
return false;
}
}
}

The problem is that I get an unknown object being thrown at me by MSIE.

What am I doing wrong? Like I say, individually the various code elements do
what they are supposed to do. I can run them in test harness HTML and they
return the results I expect. The problems arise when I try and work them
together.
Many thanks in advance

Ian

Hi,

As far as I am aware, the two can't talk to each other.
I don't think you can make them, however hard you'd try.
Try changing a hidden field and call the VBs bythe onchange, perhaps?

Kien
Jul 23 '05 #2
In article <BC***********************@btclick.com>,
ia*********@btclick.com enlightened us with...
Hi guys

I am writing a Javascript routine to check for the presence and version of
an Adobe Acrobat PDFViewer on the user's machine. No problem with any
browser on the Mac, no problem with any browser on Windows - except MSIE.


If you want code to run only in IE, you can use conditional comments
instead of trying to hack it into a javascript that is meant to run in
all browsers.

Why not use that?

http://msdn.microsoft.com/workshop/a...comment_ovw.as
p

Modify this to call your VB function (outside of the rest of your
script).

<!--[if IE 5]>
<SCRIPT LANGUAGE="Javascript">
alert("Congratulations. You are running IE5 or later!");
</SCRIPT>
<P>Thank you for closing the message box.</P>
<![endif]-->

--
--
~kaeli~
Contrary to popular opinion, the plural of 'anecdote' is
not 'fact'.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #3


Ian Sedwell wrote:

I am writing a Javascript routine to check for the presence and version of
an Adobe Acrobat PDFViewer on the user's machine. No problem with any
browser on the Mac, no problem with any browser on Windows - except MSIE.

However, I can write a routine in VBScript to cover the MSIE requirement. So
that's cool.
There shouldn't be anything your VBScript in a HTML page in IE does that
you couldn't do with JavaScript in a HTML page in IE.
Both the js and vb elements work fine. So I have no problem with core
functionality.

Naturally, my js and vb scripts are in different files and I reference each
of these in the <head> of the HTML document that contains the js function
that makes the initial call.

The initial call is made to a js routine called "checkPDFViewer()". This
calls another js routine called "getAcrobatVersionJS()". This first of all
checks the platform and if it is not one that it knows about, it simply
returns -1. This result is the cue for "checkPDFViewer()" to call the vb
routine "getAcrobatVersionVB()".

Thus...

function checkPDFViewer () {
acrobatVersion = getAcrobatVersionJS();

if (acrobatVersion > -1) {
return true;
}
else {
acrobatVersion = getAcrobatVersionVB();

if (acrobatVersion > -1) {
return true;
}
else {
return false;
}
}
}

The problem is that I get an unknown object being thrown at me by MSIE.
On what line?
How does the VBScript code look like?
Better yet put the example page online and post a URL. It can have
various reasons, for instance the order of your script elemens with the
language determines which language IE/Win assumes as the scripting
language for event handlers.
What am I doing wrong? Like I say, individually the various code elements do
what they are supposed to do. I can run them in test harness HTML and they
return the results I expect. The problems arise when I try and work them
together.


Just be aware that all those plugin checks are prone to fail for various
reasons, you can set up other applications than Adobe Acrobat viewer to
view PDF files on a machine, you can set up Adobe Acrobat viewer as an
application but disable it as a plugin for Mozilla/Netscape for instance.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #4
DU
Ian Sedwell wrote:
Hi guys

I am writing a Javascript routine to check for the presence and version of
an Adobe Acrobat PDFViewer on the user's machine. No problem with any
browser on the Mac, no problem with any browser on Windows - except MSIE.

I would first search very carefully the adobe.com site looking for
reliable answers on this. It's not that people who replied to you are
not capable or anything. I just feel that the first step would be to
examine carefully what adobe.com proposes regarding detection of Acrobat
presence and version.

There is an entirely different approach too. Let the user know that this
link or that link is a .pdf resource. That way, he can make the decision
on his own (1). Use a small image to indicate a .pdf file on the right
side of the link; use the title attribute to indicate so in the <a>
element. Also, provide an html alternative for users who do not have
acrobat reader installed or who don't want to fire acrobat reader or
whatever reason.

Once browsers support well CSS3 selectors and will want to hard-code
cursors to identify links accordingly, then

a[href$=".pdf"]:not([onclick]) {cursor: downloadpdf.cur !important, auto;}

Whatever you do, your code (and webpage requirements, goals) should be
working in a script disabled/non-existent environment and should provide
an alternative to .pdf file. There are a lot of usability studies
available already documenting that .pdf are disliked by a wide majority
of users.

DU
--
(1)
"if your link spawns a new window, or causes another windows to "pop up"
on your display, or move the focus of the system to a new FRAME or
Window, then the nice thing to do is to tell the user that something
like that will happen." W3C Accessibility Initiative regarding popups
I'd say the same for links which fire Acrobat Reader and start a
download of a - even moderate size - .pdf file.
"Use link titles to provide users with a preview of where each link will
take them, before they have clicked on it." Ten Good Deeds in Web
Design, J. Nielsen

However, I can write a routine in VBScript to cover the MSIE requirement. So
that's cool.

Both the js and vb elements work fine. So I have no problem with core
functionality.

Naturally, my js and vb scripts are in different files and I reference each
of these in the <head> of the HTML document that contains the js function
that makes the initial call.

The initial call is made to a js routine called "checkPDFViewer()". This
calls another js routine called "getAcrobatVersionJS()". This first of all
checks the platform and if it is not one that it knows about, it simply
returns -1. This result is the cue for "checkPDFViewer()" to call the vb
routine "getAcrobatVersionVB()".

Thus...

function checkPDFViewer () {
acrobatVersion = getAcrobatVersionJS();

if (acrobatVersion > -1) {
return true;
}
else {
acrobatVersion = getAcrobatVersionVB();

if (acrobatVersion > -1) {
return true;
}
else {
return false;
}
}
}

The problem is that I get an unknown object being thrown at me by MSIE.

What am I doing wrong? Like I say, individually the various code elements do
what they are supposed to do. I can run them in test harness HTML and they
return the results I expect. The problems arise when I try and work them
together.
Many thanks in advance

Ian

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kim Forbes | last post by:
Hello all, I have simple function that I call from an alert box alert(testScore); It works fine. Unfortunately, I do not like the sound and Exclamation point icon that appears. I'd like a...
1
by: Ian Sedwell | last post by:
Hi guys Many thanks to all who replied to my original question. Actually, it's dead easy and the way I was doing it was correct the first time. You do indeed simply call the VBScript routine...
0
by: Petrucci2000 | last post by:
Is there a way to call VBScript from C# Component (COM+ Package running on Server) I am thinking of using the Process Namespace and invoking CScript.exe? Is there a better way? Thanks a lot I...
1
by: P K | last post by:
Can I call a vbscript function written for asp in asp.net code Do I have to rewrite in .net?
2
by: rodchar | last post by:
hey all, can i call a vbscript within my windows service? thanks, rodchar
3
by: MicroMoth | last post by:
Hi, I'm trying to call a Javascript function within a foreach loop. I am loop over a series of users and I want to call the JS function which opens a new window, passing in the user id to each...
10
by: Shadow Lynx | last post by:
That subject packs a whallop, so let me explain in better detail what's happening and how it relates to ASPX pages... In a nutshell, if the first <script /on a page is of type "text/vbscript",...
1
by: murali | last post by:
Hi, I wrote a vbscript function to get some values from excel at client side. This function is getting called from a button click using 'sub button1_onclick() ....' What I want now is that I...
5
by: Newbie Coder | last post by:
Hello all I have 3 functions in a javacrip file (MyScript.js), which is added to an ASP.NET 2.0 project 1) no right-click 2) no select text (copy...) 3) History.Back()' How do I call...
6
by: Ajit Goel | last post by:
Hi; We have a Javascript function which I have been tasked to move to a CSharp class. This javascript function uses Regular expression extensively. This function has a string input parameter and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.