• [JavaScript权威指南]Introduce to JavaScript


      Javascript is not java

    JavaScript and Java do, however, make a good team. The two languages have different
    sets of capabilities.

    1. JavaScript can control browser behavior and content but cannot draw graphics or perform networking.
    2. Java has no control over the browser as a whole but can do graphics, networking, and multithreading.
    3. Client-side JavaScript can interact with and control Java applets embedded in a web page,and, in this sense, JavaScript really can script Java

    JavaScript Is Not Simple

    Indeed, JavaScript appears at first glance to be a fairly simple language, perhaps of the same complexity as BASIC. JavaScript does have a
    number of features designed to make it more forgiving and easier to use for new and unsophisticated programmers.

    Beneath its thin veneer of simplicity, however, JavaScript is a full-featured programming language, as complex as any and more complex than some. Programmers who attempt to use JavaScript for nontrivial tasks often find the process frustrating if they do not have a solid understanding of the language. This book documents JavaScript comprehensively, so you can develop a sophisticated understanding of the language.

    Client-Side JavaScript Features
    Another possible use of JavaScript is for writing programs to perform arbitrary computations.You can write simple scripts, for example, that compute Fibonacci numbers, or search for JavaScript: The Defini tive Guide, 4th Edi tion@Team LiB 57 primes. In the context of the Web and web browsers, however, a more interesting
    application of the language might be a program that computed the sales tax on an online order, based on information supplied by the user in an HTML form. As mentioned earlier, the real power of JavaScript lies in the browser and document -based objects that the language supports. To give you an idea of JavaScript's potential, the following sections list and explain the important capabilities of client-side JavaScript and the objects it supports.

        document.write( ) 

      -- This method is used to dynamically output HTML text that is parsed and displayed by the web browser;

    1. Control Document Appearance and Content
    2. Control the Browser
    3. Interact with HTML Forms
    4. Inte ract with the User
    5. Read and Write Client State with Cookies
    6. Still More Features 

     JavaScript can change the image displayed by an <img> tag to produce image rollover and animation effects.
     JavaScript can interact with Java applets and other embedded objects that appear in the browser. JavaScript code can read and write the properties of these applets
    and objects and can also invoke any methods they define. This feature truly allows JavaScript to script Java.
     As mentioned at the start of this section, JavaScript can perform arbitrary computation. JavaScript has a floating-point data type, arithmetic operators that
    work with it, and a full complement of standard floating-point mathematical functions.
     The JavaScript Date object simplifies the process of computing and working with dates and times.
     The Document object supports a property that specifies the last -modified date for the current document. You can use it to automatically display a timestamp on any document.
     JavaScript has a window.setTimeout( ) method that allows a block of arbitrary JavaScript code to be executed some number of milliseconds in the future. This is
    useful for building delays or repetitive actions into a JavaScript program. In JavaScript 1.2, setTimeout( ) is augmented by another useful method called setInterval( ).

     The Navigator object (named after the Netscape web browser, of course) has variables that specify the name and version of the browser that is running, as well
    as variables that identify the platform on which it is running. These variables allow scripts to customize their behavior based on browser or platform, so that they can
    take advantage of extra capabilities supported by some versions or work around bugs that exist on some platforms.
     In client-side JavaScript 1.2, the Screen object provides information about the size and color-depth of the monitor on which the web browser is being displayed.

     As of JavaScript 1.1, the scroll( ) method of the Window object allows JavaScript programs to scroll windows in the X and Y dimensions. In JavaScript 1.2, this
    method is augmented by a host of others that allow browser windows to be moved and resized.

    What JavaScript Can't Do

     JavaScript does not have any graphics capabilities, except for the power ful ability to dynamically generate HTML (including images, tables, frames, forms, fonts, etc.) for the browser to display.
     For security reasons, client-side JavaScript does not allow the reading or writing of files. Obviously, you wouldn't want to allow an untrusted program from any random web site to run on your computer and rearrange your files!
     JavaScript does not support networking of any kind, except that it can cause the browser to download arbitrary URLs and it can send the contents of HTML forms
    across the network to server-side scripts and email addresses.

               


  • 相关阅读:
    探索Javascript 异步编程
    前端性能调优
    怎样选择前端框架
    前端地图截屏方案
    不一样的山顶角
    前后端分离场景下的另类登录认证方案
    React Diff 算法
    纯css实现Magicline Navigation(下划线动画导航菜单)
    Tinymce group plugin
    自适应process组件
  • 原文地址:https://www.cnblogs.com/yingzi/p/2370114.html
Copyright © 2020-2023  润新知