Jump to content

Talk:Client-side JavaScript

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 69.237.151.124 (talk) at 20:11, 31 October 2009 (New-Player. Thank you.~~~~~). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Merge with JavaScript

I have proposed a merge with JavaScript, please see the talk page in JavaScript. Bamkin 19:02, 22 July 2007 (UTC)[reply]

Reference to base2 project

I think it's useful to create a reference to the base2-project [1] in the section Incompatibilities, but since I'm a project member, I rather think someone else should change this. —Preceding unsigned comment added by Doekman (talkcontribs) 10:25, 11 May 2008 (UTC)[reply]

Fair use rationale for Image:Js-hello world.png

Image:Js-hello world.png is being used on this article. I notice the image page specifies that the image is being used under fair use but there is no explanation or rationale as to why its use in this Wikipedia article constitutes fair use. In addition to the boilerplate fair use template, you must also write out on the image description page a specific explanation or rationale for why using this image in each article is consistent with fair use.

Please go to the image description page and edit it to include a fair use rationale. Using one of the templates at Wikipedia:Fair use rationale guideline is an easy way to insure that your image is in compliance with Wikipedia policy, but remember that you must complete the template. Do not simply insert a blank template on an image page.

If there is other fair use media, consider checking that you have specified the fair use rationale on the other images used on this page. Note that any fair use images lacking such an explanation can be deleted one week after being tagged, as described on criteria for speedy deletion. If you have any questions please ask them at the Media copyright questions page. Thank you.

BetacommandBot (talk) 23:49, 2 January 2008 (UTC)[reply]

MIME type

According to <http://www.ietf.org/rfc/rfc4329.txt>, the "new" MIME type for JavaScript is "application/javascript" and not "text/javascript". As I do not know if changing this works well with contemporary webbrowsers, I better leave it for someone more knowledged... 84.189.219.143 (talk) 00:22, 5 July 2008 (UTC)[reply]

I added something about the missing support for application/javascript in Internet Explorer. Maybe someone can rewrite that section to clarify it a bit.
78.27.52.235 (talk) 22:20, 6 October 2009 (UTC)[reply]

Save-As

What is the rationale behind not allowing Client-Side JavaScript to invoke a 'Save-As' dialog? I can't imagine that the security would be any different than linking to a file, since both could contain identical information and could be called at the same time. This seems to be crippling - "you can make any app you want in JavaScript, so long as you never need to save a file." JavaScript could truly become the 'does everything' programming language if it had this one ability. —Preceding unsigned comment added by 70.192.2.92 (talk) 07:52, 8 August 2009 (UTC)[reply]

New-Player

<mode>struct) allow related data elements to be combined and manipulated as a unit. C program source text is free-format, using the semicolon as a statement terminator (not a delimiter). <mode>{ ... } rather than either of ALGOL 60's <mode>begin ... end or ALGOL 68's <mode>( ... ) <mode>.EQ. in Fortran or the equal-sign in BASIC and ALGOL) <mode>&& and <mode>|| in place of ALGOL's "∧" (AND) and "∨" (OR) (these are semantically distinct from the bit-wise operators <mode>& and <mode>| because they will never evaluate the right operand if the result can be determined from the left alone (short-circuit evaluation)). <mode>+=, <mode>++, etc. (Equivalent to ALGOL 68's <mode>+:= and <mode>+:=1 operators) <mode>struct or <mode>union type is supported) <mode>A..B notation used in several languages <mode>_Bool type, but it was not retrofitted into the language's existing Boolean contexts. One can simulate a Boolean datatype, e.g. with <mode>enum { false, true } bool;, but this does not provide all of the features of a separate Boolean datatype.</ref> <mode>errno variable and/or special return values <mode>fflush() on a stream opened for input is an example of a different kind of undefined behavior, not necessarily a programming error but a case for which some conforming implementations may provide well-defined, useful semantics (in this example, presumably discarding input through the next new-line) as an allowed extension. Use of such nonstandard extensions generally but not always limits software portability. <mode>struct types, the C language had become powerful enough most of the Unix kernel was rewritten in C. This was one of the first operating system kernels implemented in a language other than assembly. (Earlier instances include the Multics system (written in PL/I), and MCP (Master Control Program) for the Burroughs B5000 written in ALGOL in 1961.) <mode>long int data type <mode>unsigned int data type <mode>=op (such as <mode>=-) were changed to the form op <mode>= to remove the semantic ambiguity created by such constructs as <mode>i=-10, which had been interpreted as <mode>i =- 10 instead of the possibly intended <mode>i = -10

<mode>

<mode>long int SomeFunction();
<mode>
<mode> CallingFunction()
<mode>{
<mode>    long int test1;
<mode>    register  test2;
<mode>
<mode>    test1 = SomeFunction();
<mode>    if (test1 > 0) 
<mode>          test2 = 0;
<mode>    else 
<mode>          test2 = OtherFunction();
<mode>
<mode>    return test2;
<mode>}
<mode>
<mode>

<mode>int declarations were be omitted in Mode/C. <mode>void functions <mode>struct or <mode>union types (rather than pointers) <mode>struct data types <mode>void pointers, support for international character sets and locales, and preprocessor enhancements. The syntax for parameter declarations was also augmented to include the style used in C++, although the K&R interface continued to be permitted, for compatibility with existing source code. <mode>__STDC__ macro can be used to split the code into Standard and K&R sections to take advantage of features available only in Standard C. <mode>long long int and a <mode>complex type to represent complex numbers), variable-length arrays, support for variadic macros (macros of variable arity) and support for one-line comments beginning with <mode>//, as in BCPL or C++. Many of these had already been implemented as extensions in several C compilers. <mode>int implicitly assumed. A standard macro <mode>__STDC_VERSION__ is defined with value <mode>199901L to indicate C99 support is available. GCC, Sun Studio and other C compilers now support many or all of the new features of C99. <mode>/* and <mode>*/, or (in C99) following <mode>// until the end of the line. <mode>struct, <mode>union, and <mode>enum, or assign types to and perhaps reserve storage for new variables, usually by writing the type followed by the variable name. Keywords such as <mode>char and <mode>int specify built-in types. Sections of code are enclosed in braces ( <mode>{ and <mode>}, sometimes called "curly brackets") to limit the scope of declarations and to act as a single statement for control structures. <mode>if(- <mode>else) conditional execution and by <mode>do- <mode>while, <mode>while, and <mode>for iterative execution (looping). The <mode>for statement has separate initialization, testing, and reinitialization expressions, any or all of which can be omitted. <mode>break and <mode>continue can be used to leave the innermost enclosing loop statement or skip to its reinitialization. There is also a non-structured <mode>goto statement which branches directly to the designated label within the function. <mode>switch selects a <mode>case to be executed based on the value of an integer expression. <mode>&&, <mode>||, <mode>?: and the comma operator). This permits a high degree of object code optimization by the compiler, but requires C programmers to take more care to obtain reliable results than is needed for other programming languages. <mode>== binding more tightly than <mode>& and <mode>| in expressions like <mode>x & 1 == 0. <mode>= operator, used in mathematics for equality, to indicate assignment, following the precedent of Fortran, PL/I, and BASIC, but unlike ALGOL and its derivatives. Ritchie made this syntax design decision consciously, based primarily on the argument assignment occurs more often than comparison. <mode>= and <mode>==), making it easy to accidentally substitute one for the other. C's weak type system permits each to be used in the context of the other without a compilation error (although some compilers produce warnings). For example, the conditional expression in <mode>if (a=b) is only true if <mode>a is not zero after the assignment.[1] <mode>+]], <mode>-, <mode>*, <mode>/, <mode>%) <mode>==]], <mode>!=) <mode><, <mode><=, <mode>>, <mode>>=) <mode>!, <mode>&&, <mode>||) <mode>~, <mode>&, <mode>|, <mode>^) <mode><<, <mode>>>) <mode>=, <mode>+=, <mode>-=, <mode>*=, <mode>/=, <mode>%=, <mode>&=, <mode>|=, <mode>^=, <mode><<=, <mode>>>=) <mode>++, <mode>--) <mode>&, <mode>*, <mode>[ ]) <mode>? :]]) <mode>., <mode>->) <mode>( )) <mode>sizeof) <mode>( )) <mode>,]]) <mode>( )) <mode>main() <mode>{ <mode> printf("hello, world\n"); <mode>} <mode></source>

<mode>

</code>
<mode>#include <stdio.h></code>
<mode>int main(void)</code>
<mode>{</code>
<mode>    printf("hello, world\n");</code>
<mode>    return 0;</code>
<mode>}</code>
<mode>

<mode>#include. This causes the preprocessor — the first tool to examine source code as it is compiled — to substitute the line with the entire text of the <mode>stdio.h standard header, which contains declarations for standard input and output functions such as <mode>printf. The angle brackets surrounding <mode>stdio.h indicate <mode>stdio.h is located using a search strategy prefers standard headers to other headers having the same name. Double quotes may also be used to include local or project-specific header files. <mode>main is being defined. The <mode>main function serves a special purpose in C programs: The run-time environment calls the <mode>main function to begin program execution. The type specifier <mode>int indicates the return value, the value is returned to the invoker (in this case the run-time environment) as a result of evaluating the <mode>main function, is an integer. The keyword <mode>void as a parameter list indicates the <mode>main function takes no arguments.[2] <mode>main function. <mode>printf, which was declared in <mode>stdio.h and is supplied from a system library. In this call, the <mode>printf function is passed (provided with) a single argument, the address of the first character in the string literal <mode>"hello, world\n". The string literal is an unnamed array with elements of type <mode>char, set up automatically by the compiler with a final 0-valued character to mark the end of the array ( <mode>printf needs to know this). The <mode>\n is an escape sequence C translates to a newline character, which on output signifies the end of the current line. The return value of the <mode>printf function is of type <mode>int, but it is silently discarded since it is not used. (A more careful program might test the return value to determine whether or not the <mode>printf function succeeded.) The semicolon <mode>; terminates the statement. <mode>main function and causes it to return the integer value 0, which is interpreted by the run-time system as an exit code indicating successful execution. <mode>main function. <mode>enum). C99 added a boolean datatype. There are also derived types including arrays, pointers, records ( <mode>struct), and untagged unions ( <mode>union). <mode>struct objects linked together using pointers. Pointers to functions are useful for callbacks from event handlers. <mode>void *) point to objects of unknown type, and can therefore be used as "generic" data pointers. Since the size and type of the pointed-to object is not known, void pointers cannot be dereferenced, nor is pointer arithmetic on them allowed, although they can easily be (and in many contexts implicitly are) converted to and from any other object pointer type. <mode>malloc function, and treat it as an array. C's unification of arrays and pointers (see below) means true arrays and these dynamically-allocated, simulated arrays are virtually interchangeable. Since arrays are always accessed (in effect) via pointers, array accesses are typically not checked against the underlying array size, although the compiler may provide bounds checking as an option. Array bounds violations are therefore possible and rather common in carelessly written code, and can lead to various repercussions, including illegal memory accesses, corruption of data, buffer overruns, and run-time exceptions. <mode>x[i] can also be used when <mode>x is a pointer; the interpretation (using pointer arithmetic) is to access the <mode>(i+1)th of several adjacent data objects pointed to by < <mode>x, counting the object <mode>x points to (which is <mode>x[0]) as the first element of the array. <mode>x[i] is equivalent to <mode>*(x + i). Since the type of the pointer involved is known to the compiler at compile time, the address <mode>x + i points to is not the address pointed to by <mode>x incremented by <mode>i bytes, but rather incremented by <mode>i multiplied by the size of an element <mode>x points to. The size of these elements can be determined with the operator <mode>sizeof by applying it to any dereferenced element of <mode>x, as in <mode>n = sizeof *x or <mode>n = sizeof x[0]. <mode>sizeof array), the name of an array is automatically converted to a pointer to the array's first element; this implies an array is never copied as a whole when named as an argument to a function, but rather only the address of its first element is passed. Therefore, although C's function calls use pass-by-value semantics, arrays are in effect passed by reference. <mode>a can be determined as <mode>sizeof a / sizeof a[0]. <mode>i[x] = 1;, which has the index variable <mode>i apparently interchanged with the array variable <mode>x. This last line might be found in obfuscated C code.

<mode>

</code>
<mode>/* x designates an array */</code>
<mode>x[i] = 1;</code>
<mode>x*(x + i) = 1;</code>
<mode>*(i + x) = 1;</code>
<mode>i[x] = 1; /* strange, but correct: i[x] is equivalent to *(i + x) */</code>
<mode>

<mode>memcpy function, for example.) <mode>malloc from a region of memory called the heap; these blocks persist until subsequently freed for reuse by calling the library function <mode>free <mode>malloc for an example of dynamically allocated arrays). <mode>free() has been called, then memory cannot be recovered for later reuse and is essentially lost to the program, a phenomenon known as a memory leak. Conversely, it is possible to release memory too soon and continue to access it; however, since the allocation system can re-allocate or itself use the freed memory, unpredictable behavior is likely to occur when the multiple users corrupt each other's data. Typically, the symptoms will appear in a portion of the program far removed from the actual error. Such issues are ameliorated in languages with automatic garbage collection or RAII. <mode>-lm, shorthand for "math library"). <mode>(C) 2009. Mode/Code (TM) Language is a trademark of M. Michael Musatov and MeAmI (http://www.meami.org) 'Search for the People!'(TM) <mode>application/javascript, which I registered in 2009 but is supported by all major browsers. Internet Explorer processes scripts with the attribute <mode>type="application/javascript". The HTML 4.01 and HTML 5 specifications mention the registered <mode>text/javascript, which is supported by all major browsers and is more commonly used.

<mode>

</code>
<mode><script type="application/javascript"></code>
<mode>

<mode>

</code>
<mode></script></code>
<mode>

<mode>

</code>
<mode><script language="JavaScript" type="text/javascript"></code>
<mode><!--</code>
<mode>

<mode>

</code>
<mode>// --></code>
<mode></script></code>
<mode>

<mode><!-- ... <mode>--> comment markup is required in order to ensure that the code is not rendered as text by very old browsers which do not recognize the <mode><script> tag in HTML documents (although <mode>script</tt-tags contained within the <mode>head-tag will never be rendered, thus the comment markup is not always necessary), and the LANGUAGE attribute is a deprecated HTML attribute which may be required for old browsers. However, <mode><script> tags in XHTML/XML documents will not work if commented out, as conformant XHTML/XML parsers ignore comments and also may encounter problems with <mode>--, <mode>< and <mode>> signs in scripts (for example, the integer decrement operator and the comparison operators). XHTML documents should therefore have scripts included as XML CDATA sections, by preceding them with

<mode>

</code>
<mode><script type="application/javascript"></code>
<mode>//<![CDATA[</code>
<mode>

<mode>

</code>
<mode>//]]></code>
<mode></script></code>
<mode>

<mode>// at the start of a line marks a JavaScript comment, which prevents the <mode></code><![CDATA[ and <mode>]]> from being parsed by the script.)

<mode>

</code>
<mode><script type="application/javascript" src="hello.js"></script></code>
<mode>

<mode>language is used in the following context:

<mode>

</code>
<mode><script language="JavaScript" src="hello.js"></script></code>
<mode>

<mode>

</code>
<mode><meta http-equiv="Content-Script-Type" content="application/javascript" /></code>
<mode>

<mode>

</code>
<mode>javascript:alert('Hello, world!');</code>
<mode>

<mode>.pop(), .push(), .shift(), and .unshift() methods of arrays.

<mode>

</code>
<mode>function set_image_source ( imageName, imageURL )</code>
<mode>{</code>
<mode>    if ( document.images ) // a test to discern if the 'document' object has a property called 'images' which value type-converts to boolean true (as object references do)</code>
<mode>    {</code>
<mode>        document.images[imageName].src = imageURL; // only executed if there is an 'images' collection</code>
<mode>    }</code>
<mode>}</code>
<mode>

<mode>

</code>
<mode> if ( document.body && document.body.style )</code>
<mode>

<mode>document.body.style" would ordinarily cause an error in a browser that does not have a " <mode>document.body" property, but using the boolean operator " <mode>&&" ensures that " <mode>document.body.style" is never called if "document.body" doesn't exist. This technique is called minimal evaluation.

<mode>

<mode>(C) 2009. Mode/Code (TM) Language is a trademark of M. Michael Musatov and MeAmI (http://www.meami.org) 'Search for the People!'(TM)

  1. ^ "10 Common Programming Mistakes in C". Cs.ucr.edu. Retrieved 2009-06-26.
  2. ^ The <mode>main function actually has two arguments, <mode>int argc and <mode>char *argv[], respectively, which can be used to handle command line arguments. The C standard requires both forms of <mode>main be supported, which is special treatment not afforded any other function.