Web Analytics Made Easy -
StatCounter Newbie Scripting Help - CodingForum


No announcement yet.

Newbie Scripting Help

  • Filter
  • Time
  • Show
Clear All
new posts

  • Newbie Scripting Help

    I had a java script, that would open a series of applications and urls with a button.So that i would have to open each one manually.Im very new at java I can get my script to open urls but cant get .exe to open in my script. Any feeback or scripts would be great.


  • #2
    JavaScript is not Java.

    Javascript is a very limited language for security reasons.

    It's beyond the scope of javascript to launch applications.
    (well, not really as you'll see shortly).

    If you're using a MS Windows implementation with active desktop enabled then do the following...

    paste the code below into notepad and "save as..." "desktop.html" (any filename with.html would work)
    <script type="text/javascript">
    function setBG(){
    <body id="bod">
    <div style="float:right">
    <input type="file" id="myFile" />
    <button onclick="window.open('file:///'+document.getElementById('myFile').value)">Open</button><br>
    <a href="#" onclick="setBG();return false;">Set as background</a>
    Right click on an empty place on the desktop and select "properties"

    Click on the "desktop" tab.

    Click the browse button to change your desktop background.

    Browse to and open the location of the "desktop.html" file you created.

    Click the "ok" button to accept your changes.

    On your desktop you will see a file input field, an open button and a link.
    click browse...
    select a file.
    press open.
    Windows will open the file you selected just as if you had double clicked it from the file explorer (uses file associations to find the correct application).

    you can even launch executable programs, shortcuts, .BAT files... you name it.

    If the file you browse to is an image format, you can click the link
    "set as background"
    and the image will become your desktop background.

    Note: you can also use cookies with the javascript to store values and return them upon next boot (such as the background image prefrence...)

    I use this approach on all of my windows PCs.
    My desktop has no shortcuts. Instead it has embedded drop down and slide out windows on every edge and a "tetris" javascript game allways running in the center...

    As an alternative try using the html <object> and/or <embed> tags to execute code via your html/javascript.

    ActiveX comes to mind (and sends shivers of dread down my spine).
    Last edited by VortexCortex; Oct 10, 2006, 09:28 PM. Reason: Silly typo


    • #3
      ActiveX comes to mind (and sends shivers of dread down my spine).
      If you don't want active desktop enabled; you could also save it as a .hta in which case, active x is not so terrible to use and can be quite handy. Saving it as an html application also lifts many security restrictions that your browser would otherwise impose on your javascript.

      Helping to build a bigger box. - Adam Matthews