position of vbscript in js causing errors

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Beemer Biker

    position of vbscript in js causing errors

    I put together a few lines of vbscript so I could dump the contents of a
    string to my C drive. It worked fine in a small test.htm where I put the
    vbscript at the top of the file. It failed to work (no error message) in my
    large program where I needed to dump out the stuff. I did get an error
    message from FrontPage 2003 but it was not informative.

    When moved the vbscript to the bottom of the page it worked fine!

    ========start of page======
    This is a snippet of the code showing the position at the top of the source
    code.

    <SCRIPT LANGUAGE="VBScr ipt" TYPE="text/vbscript">
    Function vbWriteText(str , strFilename)
    dim objFSO, objTextFile
    set objFSO = CreateObject("S cripting.FileSy stemObject")
    set objTextFile = objFSO.OpenText File(strFilenam e,2,true,0)
    objTextFile.Wri teLine(str)
    objTextFile.Clo se
    end Function
    </SCRIPT>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=utf-8">


    <SCRIPT language=javasc ript>
    function make()
    {
    ....a lot of js code...
    <META content="MSHTML 6.00.5700.6" name=GENERATOR> </HEAD>
    <BODY>
    ....lot of html...
    ....
    *** reference to make() in body of the page ***
    ....
    </BODY></HTML>
    ====end of page====

    When using MS FrontPage 2003, selecting Preview indicates an error occured
    at the reference to "make()" That is the first javascript function in the
    javascript code. So it would seem that putting the vbscript before the
    javascript caused the body of the page to have trouble finding make() ?
    Currently the page works fine with the vbscript at the bottom. I like to
    keep functions at the top when I code and I dont see why it could not go
    there. I do not understand why my small test program worked but the larger
    one didnt (unless I moved the code to the bottom). The larger one is much
    more complicated.

    ...thanks..
    --
    =============== =============== =============== =============== ===========
    Beemer Biker joestateson at grandecom dot net

    http://ResearchRiders.org Ask about my 99'R1100RT
    =============== =============== =============== =============== ===========


  • Martin Honnen

    #2
    Re: position of vbscript in js causing errors



    Beemer Biker wrote:
    I put together a few lines of vbscript so I could dump the contents of a
    string to my C drive. It worked fine in a small test.htm where I put the
    vbscript at the top of the file. It failed to work (no error message) in my
    large program where I needed to dump out the stuff. I did get an error
    message from FrontPage 2003 but it was not informative.
    >
    When moved the vbscript to the bottom of the page it worked fine!
    If you use more than one script language in a HTML document with
    Internet Explorer then the language or type attribute of the first
    <scriptelemen t in your document determines the script language IE uses
    for event handlers. Thus if you have <script type="text/vbscript"as
    the first script element in the document then your event handlers by
    default need to be written in VBScript and not JavaScript.
    IE additionally allows you to specify the event handler script language
    for any element with e.g.
    <input language="JavaS cript" onclick="f();"
    but that is not a good idea on the web in general.
    IE furthermore allows you to specify the script language using e.g.
    <input onclick="javasc ript: f();"
    but in general on the web that is not a good idea either.
    If you really think you need JavaScript and VBScript in one HTML
    document and you want JavaScript to be the language IE uses for event
    handlers then put a <script type="text/javascript"firs t in your
    document before all other <scriptelements .



    --

    Martin Honnen

    Comment

    • David Berry

      #3
      Re: position of vbscript in js causing errors

      What was the error message? Is this an ASP page or HTM page? If it worked
      at the bottom of the page why move it?


      "Beemer Biker" <jstateson@swri .eduwrote in message
      news:12isj60toq q4t7f@corp.supe rnews.com...
      >I put together a few lines of vbscript so I could dump the contents of a
      >string to my C drive. It worked fine in a small test.htm where I put the
      >vbscript at the top of the file. It failed to work (no error message) in
      >my large program where I needed to dump out the stuff. I did get an error
      >message from FrontPage 2003 but it was not informative.
      >
      When moved the vbscript to the bottom of the page it worked fine!
      >
      ========start of page======
      This is a snippet of the code showing the position at the top of the
      source code.
      >
      <SCRIPT LANGUAGE="VBScr ipt" TYPE="text/vbscript">
      Function vbWriteText(str , strFilename)
      dim objFSO, objTextFile
      set objFSO = CreateObject("S cripting.FileSy stemObject")
      set objTextFile = objFSO.OpenText File(strFilenam e,2,true,0)
      objTextFile.Wri teLine(str)
      objTextFile.Clo se
      end Function
      </SCRIPT>
      >
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
      <HTML><HEAD>
      <META http-equiv=Content-Type content="text/html; charset=utf-8">
      >
      >
      <SCRIPT language=javasc ript>
      function make()
      {
      ...a lot of js code...
      <META content="MSHTML 6.00.5700.6" name=GENERATOR> </HEAD>
      <BODY>
      ...lot of html...
      ...
      *** reference to make() in body of the page ***
      ...
      </BODY></HTML>
      ====end of page====
      >
      When using MS FrontPage 2003, selecting Preview indicates an error occured
      at the reference to "make()" That is the first javascript function in
      the javascript code. So it would seem that putting the vbscript before
      the javascript caused the body of the page to have trouble finding make()
      ? Currently the page works fine with the vbscript at the bottom. I like
      to keep functions at the top when I code and I dont see why it could not
      go there. I do not understand why my small test program worked but the
      larger one didnt (unless I moved the code to the bottom). The larger one
      is much more complicated.
      >
      ..thanks..
      --
      =============== =============== =============== =============== ===========
      Beemer Biker joestateson at grandecom dot net

      http://ResearchRiders.org Ask about my 99'R1100RT
      =============== =============== =============== =============== ===========
      >

      Comment

      Working...