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 9 of 9
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is it possible to use client side .js file to load a local .html file?

    Hi,

    I have a .js file, we want to make it to load a html file right next
    to it, both files are on client system. I couldn't find any such
    examples and some posts talked about JavaScript security issues, I
    wonder if it is related to what I want.


    Please suggest, and even better, provide sample or pseudo code.


    Someone said .js file is not really JaveScript file, though Microsoft
    named it 'JavaScript'.

    Please also note that I am trying to "call" .html file from the .js file, not embed html code in .js.


    Thanks,
    Peter

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    I have a .js file, we want to make it to load a html file right next
    to it, both files are on client system.
    Ummm...

    (a) What does "right next to it" mean??

    (b) Do you want to do this IN A BROWSER? Or do you really mean you want to execute the ".js" file's code via the Windows Script Host?

    (c) In any case, if both files are on the client, then you could have a security issue, if you want to do this with a browser.

    Maybe you could show us some of the code in that file??

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    the .js file wont run on it's own, it needs an HTML shell.
    if the files are in the same folder, you can simply ask for them by file name.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5

  • #4
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your reply.

    a) 'right next' means both file are in the same folder or under the same parent folder (haven't decided yet).

    b) Well, I think I meant to execute the '.js' file with WSH. I am not 100% sure because the '.js' file will be called by a 'widget' file (.kon, which is an xml file), Yahoo!Widget engine has a function "include()" so you can 'include' a .js file instead to embed js code inside the xml file. So I don't think .kon call the .js file via BROWSER.

    c) That's right (they both are on client) and that's what I have problem with. Is there any way to avoid this? Such as using different script (vbs) or other ways to launch .html files?


    Thanks,
    Peter

  • #5
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I forgot to post the sample code - it's simple though.

    Here is the widget code (.kon file):

    <?xml version="1.0" encoding="UTF-8"?>
    <widget debug="on">


    <window>
    <image name="skin">
    <src>Resources/dividerart.jpg</src>
    </image>
    <image>
    <src>Resources/button.png</src>
    <hOffset>150</hOffset>
    <vOffset>80</vOffset>
    <onMouseUp>
    openURL("www.msn.com"); //as example
    </onMouseUp>
    </image>
    </window>

    <action trigger="onMouseUp">
    include("main.js");
    </action>

    </widget>
    And simply a separate "main.js" file that try to launch an html file (in the same directory, or parent/sub directories).

    Please note that I have tried to find a way to directly launch .html file from the .kon file, but no luck yet.


    Thanks,
    Peter

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    rnd_me: No, if you are running on Windows, then you *can* use JScript (almost the same as JavaScript...MS dialect thereof) in "standalone" mode thanks to the MS's inclusion of the Windows Script Host. Essentially, this is one way that MS makes up for the lack of a decent command language, a replacement of sorts for the various Linux "shell" languages.

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Peter: I think you need to ask your question in a Yahoo Widgets forum. My *guess* would be that the Widgets engine does *not* allow you to run local scripts, because that would be a HUGE security hole. Note that browsers don't allow local scripts, by default, for the same reason. Only if a user gives explicit permission does MSIE, for example, permit a local script to run in the browser.

    http://www2.konfabulator.com/forums/

  • #8
    Regular Coder
    Join Date
    May 2009
    Location
    China
    Posts
    133
    Thanks
    1
    Thanked 1 Time in 1 Post
    Quote Originally Posted by peterbi View Post
    Hi,

    I have a .js file, we want to make it to load a html file right next
    to it, both files are on client system. I couldn't find any such
    examples and some posts talked about JavaScript security issues, I
    wonder if it is related to what I want.


    Please suggest, and even better, provide sample or pseudo code.


    Someone said .js file is not really JaveScript file, though Microsoft
    named it 'JavaScript'.

    Please also note that I am trying to "call" .html file from the .js file, not embed html code in .js.


    Thanks,
    Peter
    There is a way to do this, however i only know how to do it in FireFox/Mozilla. There is one constraint though. You can only do this in an offline webpage (run from the local filesystem).
    The other option is to write an XPI file (firefox extention that uses XUL language...which is really just XML+HTML+JS)

    In the javascript code snippets section i made a post about loading and saving data directly from the local file system.

    Save Data directly to the local file system

  • #9
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    This code will *NOT* run in a browser. At least the ".js" file won't.

    It will run in a Yahoo WIDGET. That's a special *DESKTOP* application (you know, a ".exe" in windows) that allows some limited (not sure HOW limited) usage of standard JavaScript.

    And apparently Yahoo WIDGETs have some special permissions/abilities with the local filesystem. Nothing to do with browser usage thereof.


  •  

    Posting Permissions

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