HELP Javascript causing issues

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

    HELP Javascript causing issues

    I copied the code from another HTML script that someone before me had
    written. I have no Javascript experience (I'm a VB Programmer/DBA) at
    all.

    The code below works to a certain extent. There are two things I need
    to get rid of though. One, this code keeps the calling window open
    (i.e., when you click on the URL, a new IE window opens--which is
    fine--but I can't seem to get the code right to close it. This is the
    Javascript I have so far:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

    <html>
    <head>

    <script language = "javascript ">

    function GetArg()

    {

    arg = (unescape(locat ion.href)).spli t("?");
    arg = arg[1];

    return arg;

    }

    </script>

    <title></title>

    </head>

    <body bgcolor="#00008 0">

    <p align="center"> <font size="5" color="#800000" ><b><span
    style="backgrou nd-color: #FFFFFF">Openin g
    Database</span></b></font>
    </p>

    </body>

    <script language = "javascript ">

    {

    window.navigate ("file:///C:/avail.bat");
    parent.window.c lose;

    }

    </script>

    </html>



    Avail.bat is simply the following:

    cmd /c start msaccess "C:\Jomar Based Availability with WIP.mdb"



    If you follow the URL that calls this Javascript, you get a file open
    confirmation message, which I would like to override (this URL is only
    on an intranet, so it's only going to people I know) or simply stop.

    How can I:

    1. Close the IE window that calls this Javascript once the Access
    database is open (i.e., the batch has run)?

    2. Override the confirmation message that pops up?
  • kaeli

    #2
    Re: HELP Javascript causing issues

    In article <22200799.04102 60637.2a9067e9@ posting.google. com>,
    bwhite@badgersp ortswear.com enlightened us with...[color=blue]
    > The code below works to a certain extent. There are two things I need
    > to get rid of though. One, this code keeps the calling window open
    > (i.e., when you click on the URL, a new IE window opens--which is
    > fine--but I can't seem to get the code right to close it. This is the
    > Javascript I have so far:
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">[/color]

    Um, we're up to 4.01 these days, and with no URL, it uses quirks mode. That's
    bad. However, it's also very much OT in this group. :)
    [color=blue]
    >
    > <html>
    > <head>
    >
    > <script language = "javascript ">[/color]
    The language attribute is deprecated. Use type.
    <script type="text/javascript">
    [color=blue]
    > </head>
    >
    > <body bgcolor="#00008 0">
    >
    > <p align="center"> <font size="5" color="#800000" ><b><span
    > style="backgrou nd-color: #FFFFFF">Openin g
    > Database</span></b></font>
    > </p>[/color]

    This is an old page, isn't it?
    CSS is your friend. *g*
    [color=blue]
    >
    > </body>
    >
    > <script language = "javascript ">
    >
    > {
    >
    > window.navigate ("file:///C:/avail.bat");[/color]

    window.navigate ?
    Is this for IE only? I hope so...because that's all it will work in!! *heh*
    [color=blue]
    > parent.window.c lose;[/color]
    um, what's that for?
    To close the IE window?
    But you can't do that without confirmation. It isn't nice to close people's
    windows and javascript is made to be used for the internet. It doesn't know
    you're using it for an intranet app. Unless you use an HTA. See below.
    [color=blue]
    >
    >
    >
    > If you follow the URL that calls this Javascript, you get a file open
    > confirmation message, which I would like to override (this URL is only
    > on an intranet, so it's only going to people I know) or simply stop.
    >
    > How can I:
    >
    > 1. Close the IE window that calls this Javascript once the Access
    > database is open (i.e., the batch has run)?
    >
    > 2. Override the confirmation message that pops up?
    >[/color]

    IMO...You're going about this ALL wrong.
    You want to have something that your users (who all have windows and MSIE)
    can use to open an Access file, then it closes itself with no confirmation?
    You want an HTA.

    Have a looky-see here. This just opens Excel and closes the HTA window (NOT
    the IE window that opened the HTA, just so we're clear).
    It can be opened from IE with a url or file->open or it can just be double-
    clicked or file->open from windows explorer or whatever.

    test.hta:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    "http://www.w3.org/TR/REC-html40/loose.dtd">
    <HTML>
    <HEAD>
    <TITLE>Run Executable HTA</TITLE>
    </HEAD>
    <body bgcolor=#565656 >
    <script language="javas cript" type="text/javascript">
    var oShell = new ActiveXObject(" WScript.Shell") ;
    var prog = "C:\\Progra m Files\\Microsof t Office\\Office\ \Excel.exe";
    oShell.run ('"'+prog+'"',1 );
    window.close();
    </script>
    </BODY>
    </HTML>

    --
    --
    ~kaeli~
    User: The word computer professionals use when they mean
    'idiot'.



    Comment

    • Brent White

      #3
      Re: HELP Javascript causing issues

      What is an HTA? This sounds intriguing.


      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • McKirahan

        #4
        Re: HELP Javascript causing issues

        "Brent White" <bwhite@badgers portswear.com> wrote in message
        news:417eb341$0 $24917$c397aba@ news.newsgroups .ws...[color=blue]
        > What is an HTA? This sounds intriguing.
        >
        >
        > *** Sent via Developersdex http://www.developersdex.com ***
        > Don't just participate in USENET...get rewarded for it![/color]

        Basically, an HTM file with an HTA extension.

        Strat by simply renaming any Web page.

        Next look up "HTML Application" via Google.

        Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.



        Comment

        • Brent White

          #5
          Re: HELP Javascript causing issues

          By the way, thank you for your help. You're talking to a VB programmer,
          not a web developer, so, as you probably figured, my experience in HTML
          is very limited.

          Okay, that HTA sounds pretty neat and the Excel example seems to do
          exactly what I need. I don't mind the original window staying open,
          because the calling program is a Java program, as long as no EXTRA
          windows (which was what I was finding in my example above) stay open.

          Unfortunately, I still don't have something quite right. I took your
          code and modified it to point to Microsoft Access.

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
          "http://www.w3.org/TR/REC-html40/loose.dtd">
          <HTML>
          <HEAD>
          <TITLE>Run Executable hta</title>
          </HEAD>
          <body bgcolor=#565656 >
          <script language="javas cript" type="text/javascript">
          var oShell = new ActiveXObject(" WScript.Shell") ;
          var prog = "C:\\Progra m Files\\Microsof t Office\\Office\ \msaccess.exe";
          oShell.run ('"'+prog+'"'+' C:\JomarBasedAv ailabilityWithW IP.mdb',1);
          window.close();
          </script>
          </BODY>
          </HTML>


          When I open the .hta file, it says it can not find the .mdb file, even
          though I checked the spelling, and the permissions are allowing everyone
          to access the file.

          I'd post this on Google, but it takes a long time to get a response and
          I thought Developersdex might be faster.

          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          • Brent White

            #6
            Re: HELP Javascript causing issues

            Cancel that. I think I got it straight.

            *** Sent via Developersdex http://www.developersdex.com ***
            Don't just participate in USENET...get rewarded for it!

            Comment

            • kaeli

              #7
              Re: HELP Javascript causing issues

              In article <417fa24e$0$249 02$c397aba@news .newsgroups.ws> ,
              bwhite@badgersp ortswear.com enlightened us with...[color=blue]
              > Cancel that. I think I got it straight.
              >[/color]

              Cool.
              (hta = hypertext application, by the way, and they can be standalone as well
              as web)

              If you wasnt to learn more, see
              Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


              HTA's are also cool for VB programmers because you don't have to use
              javascript. They support VBScript just fine. Since it's IE only anyway, you
              can use either language.

              HTH

              --
              --
              ~kaeli~
              Support your local medical examiner: die strangely!



              Comment

              • Brent White

                #8
                Re: HELP Javascript causing issues

                Yeah, we use IE 6 at this office, though I'm really more of a Mozilla
                fan.

                That's good to know about VBScript. I've never programmed Java in my
                life and, though I want to learn, it's a learning process.

                *** Sent via Developersdex http://www.developersdex.com ***
                Don't just participate in USENET...get rewarded for it!

                Comment

                • Andrew Thompson

                  #9
                  Re: HELP Javascript causing issues

                  On 27 Oct 2004 15:08:00 GMT, Brent White wrote:
                  [color=blue]
                  > Yeah,[/color]

                  ? Please quote a little of what you are replying to,
                  with reply directly following.
                  [color=blue]
                  >..we use IE 6 at this office, though I'm really more of a Mozilla
                  > fan.
                  >
                  > That's good to know about VBScript. I've never programmed Java..[/color]

                  kaeli did not mention Java (a language quite distinct from
                  Javascript/JScript or VB Script) at any point.

                  --
                  Andrew Thompson
                  http://www.PhySci.org/codes/ Web & IT Help
                  http://www.PhySci.org/ Open-source software suite
                  http://www.1point1C.org/ Science & Technology
                  http://www.LensEscapes.com/ Images that escape the mundane

                  Comment

                  Working...