Calling VBScript from JavaScript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ian Sedwell

    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 "getAcrobatVers ionJS()". 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 "getAcrobatVers ionVB()".

    Thus...

    function checkPDFViewer () {
    acrobatVersion = getAcrobatVersi onJS();

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

    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

  • Kien

    #2
    Re: Calling VBScript from JavaScript

    Ian Sedwell wrote:
    [color=blue]
    > 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 "getAcrobatVers ionJS()". 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 "getAcrobatVers ionVB()".
    >
    > Thus...
    >
    > function checkPDFViewer () {
    > acrobatVersion = getAcrobatVersi onJS();
    >
    > if (acrobatVersion > -1) {
    > return true;
    > }
    > else {
    > acrobatVersion = getAcrobatVersi onVB();
    >
    > 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
    >[/color]
    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

    Comment

    • kaeli

      #3
      Re: Calling VBScript from JavaScript

      In article <BCEE0B7E.84D3% ian.sedwell@btc lick.com>,
      ian.sedwell@btc lick.com enlightened us with...[color=blue]
      > 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.
      >[/color]

      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?

      Learn with interactive lessons and technical documentation, earn professional development hours and certifications, and connect with the community.

      p

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

      <!--[if IE 5]>
      <SCRIPT LANGUAGE="Javas cript">
      alert("Congratu lations. 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'.



      Comment

      • Martin Honnen

        #4
        Re: Calling VBScript from JavaScript



        Ian Sedwell wrote:

        [color=blue]
        > 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.[/color]

        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.
        [color=blue]
        > 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 "getAcrobatVers ionJS()". 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 "getAcrobatVers ionVB()".
        >
        > Thus...
        >
        > function checkPDFViewer () {
        > acrobatVersion = getAcrobatVersi onJS();
        >
        > if (acrobatVersion > -1) {
        > return true;
        > }
        > else {
        > acrobatVersion = getAcrobatVersi onVB();
        >
        > if (acrobatVersion > -1) {
        > return true;
        > }
        > else {
        > return false;
        > }
        > }
        > }
        >
        > The problem is that I get an unknown object being thrown at me by MSIE.[/color]

        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.
        [color=blue]
        > 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.[/color]

        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


        Comment

        • DU

          #5
          Re: Calling VBScript from JavaScript

          Ian Sedwell wrote:
          [color=blue]
          > 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.
          >[/color]

          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

          [color=blue]
          > 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 "getAcrobatVers ionJS()". 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 "getAcrobatVers ionVB()".
          >
          > Thus...
          >
          > function checkPDFViewer () {
          > acrobatVersion = getAcrobatVersi onJS();
          >
          > if (acrobatVersion > -1) {
          > return true;
          > }
          > else {
          > acrobatVersion = getAcrobatVersi onVB();
          >
          > 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
          >[/color]

          Comment

          Working...