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 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Uses of JavaScript within and outside of web pages?

    Hi, I'm in year 11 studying GCSE Computing and I'm working on gathering some primary research for a project. I'd be really grateful if someone with experience in web developing would be able to explain to me some of the uses of JavaScript within web pages- what have you used it for specifically?
    Also, any examples of how JavaScript is used outside of web pages would be really helpful.
    Thank you!

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by CompSciStudent View Post
    Hi, I'm in year 11 studying GCSE Computing and I'm working on gathering some primary research for a project. I'd be really grateful if someone with experience in web developing would be able to explain to me some of the uses of JavaScript within web pages- what have you used it for specifically?
    Also, any examples of how JavaScript is used outside of web pages would be really helpful.
    Thank you!
    Are you asking about JavaScript (as implied by what the question says) or about Java (implied by where you posted the question)?

    These are two completely different languages.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I meant JavaScript. I understand that they're completely different languages but I posted the question in the wrong place by accident

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Moving from Java to Javascript forum.
    Although I'm not familiar with any common way to parse Javascript outside of a browser environment, there may be a common program that does just this.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,574
    Thanks
    80
    Thanked 4,620 Times in 4,583 Posts
    On Windows, you can use JavaScript as a command scripting language (much like using PERL or shell or cshell in Linux).

    There are even two "varieties" of how you can script: If you launch JavaScript via cscript.exe you are in a command line style environment. If you launch it via wscript.exe you are in a windows environment (albeit a pretty limited one).

    You can also launch JavaScript without specifying which environment and the most recently used (or the one set via an environment variable) will be used.

    So, for example, you can drop a "xxx.js" file onto your destktop and then just clicking on the icon for it will launch it.

    The same applies for VBScript, by the by.

    And in either language, you can use ActiveX components (same as in Classic ASP pages). So you can use databases, read/write files, send email, use XMLHTTP, etc., all from a scripting environment.

    Finally, you can of course schedule tasks (much like using CRON) that execute these scripts. I do this for such things as:
    -- running database backups
    -- running daily batch processing
    -- pulling data from a database and then both hitting a website and sending email (does this every 3 minutes, actually)
    and more.

    To me, it's easier than using shell scripts in Linux ever was, because the syntax is good old JavaScript and doesn't need funky escaping, et al. I used to write some fairly complex cshell scripts, and I'd bet that I could write the same stuff in about 2/3rds the number of line in JS plus you'd be able to read and modify it a lot easier.

    But that's me.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,574
    Thanks
    80
    Thanked 4,620 Times in 4,583 Posts
    As far as using JavaScript in web pages: Look around.

    People use it for so many things it would be hard to enumerate them all.

    Such simple things as form field validation. Sliding images. Dynamic menus. Role playing games. Action games. And many many many more.

    It's hard to find a web page nowadays that is *NOT* using JavaScript.

    Just go to your favorite sites and click on the VIEW menu of your browser and then on the SOURCE or PAGE SOURCE menu item. That shows you the HTML the page is using. Including all the JavaScript code it is using. (If you do this from Firefox, and if the page has any "included" javascript files, you can click on the file reference and now you will be viewing the code in the javascript file.)
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Adobe AIR provides a way to create desktop applications using your choice of three languages - one of which is JavaScript.

    Rhino and Node appear to be two of the more popular ways of running JavaScript on a webserver.

    If you include Microsoft's JScript variant then I believe you can run that on the server as well via .NET.

    There are four places in the web browser itself where JavaScript can be run -
    1. attached to web pages (the most common place to see JavaScript used)
    2. Attached to the Bookmarks/Favorites menu where it can be selectively run against any web page
    3. as a userscript attached to the browser itself where the sites it runs on are controlled by extra statements added to the start of the script
    4. as a part of browser plugins/extensions
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,574
    Thanks
    80
    Thanked 4,620 Times in 4,583 Posts
    Quote Originally Posted by felgall View Post
    If you include Microsoft's JScript variant then I believe you can run that on the server as well via .NET.
    Not quite.

    You can run JScript via classic ASP pages, yes.

    But the variant of JavaScript that is used with ASP.NET is...well...just plain funky.

    Among other oddities, JScript.Net (as it is named) allows you to specify a type for your variables!

    example: var x : String;

    You *can* scale it back to be mostly ECMAScript compliant, but then it's harder to interface to many of the .NET libraries.

    Quite frankly, I dunno what somebody was smoking when they dreamed up JScript.Net.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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