472,779 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 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 10831
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.