[ Pobierz całość w formacie PDF ]
.document.write("Hello ", mystery, " testing ", 123)In the following example, the write method takes two arguments.The first argument is an assignment expression, and the second argument is a string literal.//Displays Hello world.msgWindow.document.write(mystr = "Hello " + "world.")In the following example, the write method takes a single argument that is a conditional expression.If the value of the variable age is less than 18, the method displays "Minor." If the value of age is greater than or equal to 18, the method displays "Adult."msgWindow.document.write(status = (age >= 18) ? "Adult" : "Minor")See also, , methodswritelnMethod.Writes one or more HTML expressions to a document in the specified window and follows them with a newline character.Syntaxdocument.writeln(expression1 [,expression2],.[,expressionN])Parametersexpression1 through expressionN are any JavaScript expressions or the properties of existing objects.Method ofImplemented inNavigator 2.0Navigator 3.0: users can print and save generated HTML using the commands on the File menuDescriptionThe writeln method displays any number of expressions in a document window.You can specify any JavaScript expression, including numerics, strings, or logicals.The writeln method is the same as the write method, except the writeln method appends a newline character to the end of the output.HTML ignores the newline character, except within certain tags such as <PRE>.Use the writeln method within any <SCRIPT> tag or within an event handler.Event handlers execute after the original document closes, so the writeln method will implicitly open a new document of mimeType text/html if you do not explicitly issue a document.open() method in the event handler.ExamplesAll the examples used for the write method are also valid with the writeln method.See also, , methods
[ Pobierz całość w formacie PDF ]