How to run a javascript

Discussion in 'Web Design and Development' started by dinggus, Feb 6, 2013.

  1. dinggus macrumors 65816

    Jan 17, 2012
    How can I run a javascript just from my computer? I'd like to test a script out.
  2. imaketouchtheme macrumors 65816

    Dec 5, 2007
    Google Chrome? View > Developer > Javascript Console
  3. dinggus, Feb 6, 2013
    Last edited: Feb 6, 2013

    dinggus thread starter macrumors 65816

    Jan 17, 2012
    Thanks, do I just enter the script info or what? Can I PM you the script code?
  4. Dunmail macrumors regular

    Mar 27, 2009
    Skipton, UK
    Simply create a web page and include the code. Save the file locally and double click it to open in your browser. If your script relies on certain elements being on the page then you'll have to add them.

    <!DOCTYPE html>
    <!-- put CSS links and meta tags here -->
    <!-- Any elements you need for your script to work -->
    <script src = "path to your script"></script>
    Depending on how you've written your script you may have to add an event handler to the body:

    <body onload="entryfunction()">
    Better is to use the IIFE (Immediately Invoked Function Expression) format at the foot of the page:

    (function (){
    // All your code here or call your entry function.
  5. 960design macrumors 68030

    Apr 17, 2012
    Destin, FL
  6. MyNameIsDave macrumors member

    May 28, 2012
    If your code depends on other libraries such as jQuery, you can try it out online at

    You can then share it with other people if you want to show them about your code (e.g. to get help with it).
  7. dinggus thread starter macrumors 65816

    Jan 17, 2012
    Thanks I shared it with Dunmail and his response was:
    So, now I'm stuck because I how no clue how who to get ahold of for the script, or create a web page with buttons to call the functions.

Share This Page