Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Jscript - Open browser to file

    First, I'm sorry if this is in the wrong forum, but I couldn't find a forum specifically for "Jscript" or "Windows Scripting". I posted here because, well, jsc.exe is in the windows-microsoft.net-framework-v#.#.##### folder.

    Also, this should be a simple matter that I've looked up but, strangely, can't seem to understand why the examples don't seem to work. I'm relatively decent with javascript for web pages, but this just confuses me.

    Question: I'm trying to write a .js file that will be compiled by jsc.exe into a win.exe file. The executable I'm wanting to write is supposed to be an alternative to an HTML redirect page. How do I do this???

    I've tried normal javascript and some variations, but still get an error when compiling... saying that "window", "document", "open", or whatever hasn't been declared when I use any of the following code lines:
    window.open('html/whatever.htm');
    document.open('html/whatever.htm');
    window.document.open('html/whatever.htm');

    I don't know what library .dll's I should import for this, if any.

    Obviously, I'm a real newby with Jscript for compiling (just started last night), any tips on learning more (not just links) faster or easier is appreciated. So far, I've been able to get as far as making a windows script popup stating date and a random number, but nothing else at this time.

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,371
    Thanks
    11
    Thanked 591 Times in 572 Posts
    you can probably use wsh to execute the file path, which should open the document in the default application.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%

  • #3
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rnd me View Post
    you can probably use wsh to execute the file path, which should open the document in the default application.
    It took some searching on the internet to find the right script code. Thanks for the tip.

    For those who are having the same problem, I'm posting the code I used:

    Code:
    var WshShell = new ActiveXObject("WScript.Shell");
    WshShell.Run("iexplore.exe path/filename.htm");
    Note that the browser application must be in the quotes, with a space before the URL, or the system will error (not jsc.exe).

    I wish I knew how to open the URL in the default browser without specifying the app. If anyone knows a better way to code this, please post it here.

  • #4
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,371
    Thanks
    11
    Thanked 591 Times in 572 Posts
    Quote Originally Posted by cnr123 View Post
    I wish I knew how to open the URL in the default browser without specifying the app. If anyone knows a better way to code this, please post it here.
    try:

    Code:
    WshShell.Run("start path/filename.htm");
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%

  • #5
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Open in new tab if browser is already running???

    Thanks again! It works pretty well.

    I don't suppose you (or anyone) knows a way to force the file to open in a tab if there's already an instance of the browser running, without permanently changing the browser settings?

    I'm guessing, probably not... or at least not easily or for beginners like me.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •