Function. Adds tainting to a data element or script.
taint(dataElementName)
Use taint to mark data that otherwise is not tainted.
In some cases, control flow rather than data flow carries tainted information. In these cases, taint is added to the script's window. You can add taint to the script's window by calling taint with no arguments. See "Tainting that results from conditional statements".
taintedStatus=taint(window.defaultStatus)
// taintedStatus now cannot be sent in a URL or form post without
// the end user's permission
domain property; taintEnabled method; untaint function; "Using data tainting for security"
Method. Specifies whether data tainting is enabled.
navigator.taintEnabled()
Use taintEnabled to determine if data tainting is enabled. taintEnabled returns true if data tainting is enabled, false otherwise. The user enables or disables data tainting by using the environment variable NS_ENABLE_TAINT.
The following code executes function1 if data tainting is enabled; otherwise it executes function2.
if (navigator.taintEnabled()) {
function1()
}
else function2()
domain property; taint, untaint functions; "Using data tainting for security"
Method. Returns the tangent of a number.
Math.tan(number)
The tan method returns a numeric value that represents the tangent of the angle.
The following function returns the tangent of the variable x:
function getTan(x) {
return Math.tan(x)
}
If you pass getTan the value Math.PI/4, it returns 0.9999999999999999.
acos, asin, atan, atan2, cos, sin methods
1. formName.target
2. links[index].target
3. areaName.target
formName is either the name of a form or an element in the forms0 array.
areaName is the value of the NAME attribute of an Area object.
Area object (see Link object), Form object, Link object
You can set the target property at any time.
document.musicInfo.target="msgWindow"
For form: action, encoding, method properties; Form object
To define a Text object, use standard HTML syntax with the addition of JavaScript event handlers:
<INPUT
TYPE="text"
NAME="textName"
VALUE="textValue"
SIZE=integer
[onBlur="handlerText"]
[onChange="handlerText"]
[onFocus="handlerText"]
[onSelect="handlerText"]>
SIZE=integer specifies the number of characters the Text object can accommodate without scrolling.
To use a Text object's properties and methods:
1. textName.propertyName
2. textName.methodName(parameters)
3. formName.elements[index].propertyName
4. formName.elements[index].methodName(parameters)
textName is the value of the NAME attribute of a Text object.
propertyName is one of the properties listed below.
methodName is one of the methods listed below.
A Text object on a form looks as follows:
A Text object is a form element and must be defined within a <FORM> tag.
Text objects can be updated (redrawn) dynamically by setting the value property (this.value).
The Text object has the following properties:
The Text object has the following methods:
<B>Last name:</B> <INPUT TYPE="text" NAME="last_name" VALUE="" SIZE=25>
<FORM NAME="form1">
<BR><B>City: </B><INPUT TYPE="text" NAME="city" VALUE="Anchorage"
SIZE="20" onFocus="this.select()">
<B>State: </B><INPUT TYPE="text" NAME="state" VALUE="AK" SIZE="2"
onChange="this.value=this.value.toUpperCase()">
</FORM>
See also the examples for the onBlur, onChange, onFocus, and onSelect event handlers.
FileUpload object, Form object, Password object, String object, Textarea object
Property. A string specifying the text that follows an <OPTION> tag in a Select object.
1. selectName.options[index].text
2. optionName.text
index is an integer representing an option in a Select object.
optionName is the name of a Select object option created using the Option() constructor.
Option object (see Select object), options array (see Select object)
The text property initially reflects the text that follows an <OPTION> tag in a Select object.
function getChoice() {
for (var i = 0; i < document.musicForm.musicType.length; i++) {
if (document.musicForm.musicType.options[i].selected == true) {
return document.musicForm.musicType.options[i].text
}
}
return null
}
The previous example assumes that the Select object is similar to the following:
<SELECT NAME="musicType">
<OPTION SELECTED> R&B
<OPTION> Jazz
<OPTION> Blues
<OPTION> New Age
</SELECT>
To define a text area, use standard HTML syntax with the addition of JavaScript event handlers:
<TEXTAREA
NAME="textareaName"
ROWS="integer"
COLS="integer"
[onBlur="handlerText"]
[onChange="handlerText"]
[onFocus="handlerText"]
[onSelect="handlerText"]>
textToDisplay
</TEXTAREA>
To use a Textarea object's properties and methods:
1. textareaName.propertyName
2. textareaName.methodName(parameters)
3. formName.elements[index].propertyName
4. formName.elements[index].methodName(parameters)
textareaName is the value of the NAME attribute of a Textarea object.
propertyName is one of the properties listed below.
methodName is one of the methods listed below.
A Textarea object on a form looks as follows:
A Textarea object is a form element and must be defined within a <FORM> tag.
Textarea objects can be updated (redrawn) dynamically by setting the value property (this.value).
To begin a new line in a Textarea object, you can use a newline character. Although this character varies from platform to platform (Unix is \n, Windows is \r, and Macintosh is \n), JavaScript checks for all newline characters before setting a string-valued property and translates them as needed for the user's platform. You could also enter a newline character programmatically--one way is to test the appVersion property to determine the current platform, then set the newline character accordingly. See the appVersion property for an example.
The Textarea object has the following properties:
The Textarea object has the following methods:
<B>Description:</B>
<BR><TEXTAREA NAME="item_description" ROWS=6 COLS=55>
Our storage ottoman provides an attractive way to
store lots of CDs and videos--and it's versatile
enough to store other things as well.
It can hold up to 72 CDs under the lid and 20 videos
in the drawer below.
</TEXTAREA>
<SCRIPT>
myString="This is line one.\nThis is line two.\rThis is line three."
</SCRIPT>
<FORM NAME="form1">
<INPUT TYPE="button" Value="Populate the textarea"
onClick="document.form1.textarea1.value=myString">
<P>
<TEXTAREA NAME="textarea1" ROWS=6 COLS=55></TEXTAREA>
See also the examples for the onBlur, onChange, onFocus, and onSelect event handlers.
Form object, Password object, String object, Text object
Property. A string representing the title of a document.
document.title
title is a read-only property.
In the following example, the value of the title property is assigned to a variable called docTitle:
var newWindow = window.open("http://home.netscape.com")
var docTitle = newWindow.document.title
Method. Converts a date to a string, using the Internet GMT conventions.
dateObjectName.toGMTString()
dateObjectName is either the name of a Date object or a property of an existing object.
The exact format of the value returned by toGMTString varies according to the platform.
In the following example, today is a Date object:
today.toGMTString()
Mon, 18 Dec 1995 17:28:35 GMT
toLocaleString method
Method. Converts a date to a string, using the current locale's conventions.
dateObjectName.toLocaleString()
dateObjectName is either the name of a Date object or a property of an existing object.
In the following example, today is a Date object:
today.toLocaleString()
12/18/95 17:28:35
toGMTString method
Method. Returns the calling string value converted to lowercase.
stringName.toLowerCase()
stringName is any string or a property of an existing object.
The following example displays the lowercase string "alphabet":
var upperText="ALPHABET"
document.write(upperText.toLowerCase())
toUpperCase method
1. top.propertyName
2. top.methodName
3. top.frameName
4. top.frames[index]
propertyName is defaultStatus, status, or length.
methodName is any method associated with the window object.
frameName and frames[index] are ways to refer to frames.
The top property is read-only. The value of the top property is
<object objectReference>
where objectReference is an internal reference.
The statement top.close()
closes the top-most
ancestor window.
<FRAMESET COLS="30%,40%,30%">
<FRAME SRC=child1.htm NAME="childFrame1">
<FRAME SRC=child2.htm NAME="childFrame2">
<FRAME SRC=child3.htm NAME="childFrame3">
</FRAMESET>
top.myFrame.document.bgColor="red"
Method. Returns a string representing the specified object.
objectName.toString()
numberObjectName.toString([radix])
objectName is the object to convert to a string.
numberObjectName is the Number object to convert to a string.
radix is an integer between 2 and 16 specifying the base to use for representing numeric values.
toString is a method of all objects.
Yes, for history, location, Link, and any form input element; No for all other objects
document.write(theDog)
document.write("The dog is " + theDog)
<IMG NAME="sealife" SRC="images\seaotter.gif" ALIGN="left" VSPACE="10">
function Dog(name,breed,color,sex) {
this.name=name
this.breed=breed
this.color=color
this.sex=sex
}
theDog = new Dog("Gabby","Lab","chocolate","girl")
function objectToString() {
var ret = "Object " + this.name + " is ["
for (var prop in this)
ret += " " + prop + " is " + this[prop] + ";"
return ret + "]"
}
The following code assigns the user-defined function to the object's toString method:
Dog.prototype.toString = objectToString
An object's toString method is usually invoked by JavaScript, but you can invoke it yourself as follows:
alert(theDog.toString())
var monthNames = new Array("Jan","Feb","Mar","Apr")
document.write("monthNames.toString() is " + monthNames.toString())
monthNames.toString() is Jan,Feb,Mar,Apr
flag = new Boolean(true)
document.write("flag.toString() is " + flag.toString() + "<BR>")
For example, suppose you create the function Dog shown in "User-defined toString methods". Any time Dog is used in a string context, JavaScript automatically calls the toString function, which returns the following string:
You can use toString on numeric values, but not on numeric literals:
// The next two lines are valid
var howMany=10
document.write("howMany.toString() is " + howMany.toString() + "<BR>")
// The next line causes an error
document.write("45.toString() is " + 45.toString() + "<BR>")
document.write("location.toString() is " + location.toString() + "<BR>")
file:///C|/TEMP/myprog.html
Example 2: Object with no string value. Suppose the following Image object named "sealife" exists:
<IMG NAME="sealife" SRC="images\seaotter.gif" ALIGN="left" VSPACE="10">
[object Image]
for (x = 0; x < 10; x++) {
document.write("Decimal: ", x.toString(10), " Binary: ",
x.toString(2), "<BR>")
}
The preceding example produces the following output:
Decimal: 0 Binary: 0
Decimal: 1 Binary: 1
Decimal: 2 Binary: 10
Decimal: 3 Binary: 11
Decimal: 4 Binary: 100
Decimal: 5 Binary: 101
Decimal: 6 Binary: 110
Decimal: 7 Binary: 111
Decimal: 8 Binary: 1000
Decimal: 9 Binary: 1001
prototype property; valueOf method
Method. Returns the calling string value converted to uppercase.
stringName.toUpperCase()
stringName is any string or a property of an existing object.
The following example displays the string "ALPHABET":
var lowerText="alphabet"
document.write(lowerText.toUpperCase())
toLowerCase method
1. objectName.type
2. navigator.mimeTypes[index].type
Button object, Checkbox object, FileUpload object, Hidden object, MimeType object, Password object, Radio object, Reset object, Select object, Submit object, Text object, Textarea object
For form elements, the value of the type property is assigned as follows:
The following example writes the value of the type property for every element on a form.
for (var i = 0; i < document.form1.elements.length; i++) {
document.writeln("<BR>type is " + document.form1.elements[i].type)
}
See also the examples for the MimeType object.
For MimeType objects: description, enabledPlugin, suffixes properties
Function. Returns the ASCII string for the specified value.
unescape("string")
The following example returns "&":
unescape("%26")
The following example returns "!#":
unescape("%21%23")
escape function
Function. Removes tainting from a data element or script.
untaint(dataElementName)
Use untaint to clear tainting that marks data that should not to be sent by other scripts to different servers.
In some cases, control flow rather than data flow carries tainted information. In these cases, taint is added to the script's window. You can remove taint from the script's window by calling untaint with no arguments, if the window contains taint only from the current window. See "Tainting that results from conditional statements".
untaintedStatus=untaint(window.defaultStatus)
// untaintedStatus can now be sent in a URL or form post by other
// scripts
domain property; taint function; "Using data tainting for security"
Property. A string specifying the complete URL of the document.
document.URL
The following example displays the URL of the current document:
document.write("The current URL is " + document.URL)
navigator.userAgent
Servers use the value sent in the user-agent header to identify the client.
userAgent is a read-only property.
The following example displays userAgent information for the Navigator:
document.write("The value of navigator.userAgent is " +
navigator.userAgent)
For Navigator 2.0, this displays the following:
The value of navigator.userAgent is Mozilla/2.0 (Win16; I)
appCodeName, appName, appVersion, javaEnabled properties
Date.UTC(year, month, day [, hrs] [, min] [, sec])
month is a month between zero and 11.
date is a day of the month between one and 31.
hrs is hours between zero and 23.
min is minutes between zero and 59.
sec is seconds between zero and 59.
The following statement creates a Date object using GMT instead of local time:
gmtDate = new Date(Date.UTC(96, 11, 1, 0, 0, 0))
parse method
Property. A string that is related to the VALUE attribute of its object.
1. objectName.value
2. radioName[index].value
3. selectName.options.[index].value
4. fileUploadName.value
5. optionName.value
radioName is the value of the NAME attribute of a Radio object.
index is an integer representing a radio button in a Radio object or an option in a Select object.
optionName is the name of a Select object option created using the Option() constructor.
Navigator 3.0: property of FileUpload, Option
The value property differs for every object.
When a VALUE attribute is not specified in HTML, the value property differs for each object:
These strings are displayed on the faces of the buttons.
value is a read-only property.
You can set the value property at any time.
value is a read-only property.
If you programmatically set the value property and then evaluate it, JavaScript returns the current value. If a user interactively modifies the value in the password field, you cannot evaluate it accurately unless data tainting is enabled. See "Using data tainting for security".
You can set the value property at any time.
You can set the value property at any time.
function valueGetter() {
var msgWindow=window.open("")
msgWindow.document.write("submitButton.value is " +
document.valueTest.submitButton.value + "<BR>")
msgWindow.document.write("resetButton.value is " +
document.valueTest.resetButton.value + "<BR>")
msgWindow.document.write("helpButton.value is " +
document.valueTest.helpButton.value + "<BR>")
msgWindow.document.close()
}
This example displays the following values:
Query Submit
Reset
Help
The previous example assumes the buttons have been defined as follows:
<INPUT TYPE="submit" NAME="submitButton">
<INPUT TYPE="reset" NAME="resetButton">
<INPUT TYPE="button" NAME="helpButton" VALUE="Help">
function valueGetter() {
var msgWindow=window.open("")
for (var i = 0; i < document.valueTest.radioObj.length; i++) {
msgWindow.document.write
("The value of radioObj[" + i + "] is " +
document.valueTest.radioObj[i].value +"<BR>")
}
msgWindow.document.close()
}
This example displays the following values:
on
on
on
on
The previous example assumes the buttons have been defined as follows:
<BR><INPUT TYPE="radio" NAME="radioObj">R&B
<BR><INPUT TYPE="radio" NAME="radioObj" CHECKED>Soul
<BR><INPUT TYPE="radio" NAME="radioObj">Rock and Roll
<BR><INPUT TYPE="radio" NAME="radioObj">Blues
Method. Returns the primitive value of the specified object.
objectName.valueOf()
objectName is the object to converted to a value.
valueOf is a method of all objects.
myNumberType.prototype.valueOf = new Function(functionText)
myNumber.valueOf()
Objects in string contexts convert via the toString method, which is different from String objects converting to string primitives via valueOf. All string objects have a string conversion, if only "[object type]". But many objects do not convert to number, boolean, or function. For information on toString, see toString.
parseInt function, toString method; "typeof"
Property. A string specifying the color of visited links.
document.vlinkColor
The vlinkColor property is expressed as a hexadecimal RGB triplet or as one of the string literals listed in "Color values". This property is the JavaScript reflection of the VLINK attribute of the <BODY> tag. The default value of this property is set by the user on the Colors tab of the Preferences dialog box, which is displayed by choosing General Preferences from the Options menu. You cannot set this property after the HTML source has been through layout.
The following example sets the color of visited links to aqua using a string literal:
document.vlinkColor="aqua"
The following example sets the color of active links to aqua using a hexadecimal triplet:
document.vlinkColor="00FFFF"
alinkColor, bgColor, fgColor, linkColor properties
imageName.vspace
imageName is either the name of an Image object or an element in the images array.
vspace is a read-only property.
See the examples for the height property.
border, height, hspace, width properties
Property. A string specifying the width of an image in pixels.
imageName.width
imageName is either the name of an Image object or an element in the images array.
width is a read-only property.
See the examples for the height property.
border, height, hspace, vspace properties
Object. The top-level object for each document, location, and history object group.
To define a window, use the open method:
windowVar = window.open("URL", "windowName" [,"windowFeatures"])
For details on defining a window, see the open (window object) method.
To use a window object's properties and methods:
1. window.propertyName
2. window.methodName(parameters)
3. self.propertyName
4. self.methodName(parameters)
5. top.propertyName
6. top.methodName(parameters)
7. parent.propertyName
8. parent.methodName(parameters)
9. windowVar.propertyName
10. windowVar.methodName(parameters)
11. propertyName
12. methodName(parameters)
To define an event handler for a window object, use the <BODY> or <FRAMESET> tags:
<BODY
...
[onBlur="handlerText"]
[onFocus="handlerText"]
[onLoad="handlerText"]
[onUnload="handlerText"]>
</BODY>
<FRAMESET
ROWS="rowHeightList"
COLS="columnWidthList"
[onBlur="handlerText"]
[onFocus="handlerText"]
[onLoad="handlerText"]
[onUnload="handlerText"]>
[<FRAME SRC="URL" NAME="frameName">]
</FRAMESET>
Note
On some platforms, placing an onBlur or onFocus event handler in a <FRAMESET> tag has no effect. Please see the release notes (after starting Netscape, choose Release Notes from the Help menu).
For information on the <BODY> and <FRAMESET> tags, see the document and Frame objects.
To define an onError event handler for a window object:
window.onerror=errorHandler
For information on specifying the onError event handler, see onError event handler.
windowName is the window name to use in the TARGET attribute of a <FORM> or <A> tag.
propertyName is one of the properties listed below.
methodName is one of the methods listed below.
The top and parent properties are also synonyms that can be used in place of the window name. top refers to the top-most Navigator window, and parent refers to a window containing a frameset. See the top and parent properties.
The window object has the following properties:
The following objects are also properties of the window object:
The window object has the following methods:
win1.html
, which defines the frames for the
first window, contains the following code:
<HTML>
<HEAD>
<TITLE>Window object example: Window 1</TITLE>
</HEAD>
<BODY BGCOLOR="antiquewhite">
<SCRIPT>
window2=open("win2.html","secondWindow",
"scrollbars=yes,width=250, height=400")
document.writeln("<B>The first window has no name: "
+ window.name + "</B>")
document.writeln("<BR><B>The second window is named: "
+ window2.name + "</B>")
</SCRIPT>
<FORM NAME="form1">
<P><INPUT TYPE="button" VALUE="Open a message window"
onClick = "window3=window.open('','messageWindow',
'scrollbars=yes,width=175, height=300')">
<P><INPUT TYPE="button" VALUE="Write to the message window"
onClick="window3.document.writeln('Hey there');
window3.document.close()">
<P><INPUT TYPE="button" VALUE="Close the message window"
onClick="window3.close()">
<P><INPUT TYPE="button" VALUE="Close window2"
onClick="window2.close()">
</FORM>
</BODY>
</HTML>
win2.html
, which defines the content for
window2, contains the following code:
<HTML>
<HEAD>
<TITLE>Window object example: Window 2</TITLE>
</HEAD>
<BODY BGCOLOR="oldlace"
onLoad="alert('Message from ' + window.name + ': Hello, World.')"
onUnload="alert('Message from ' + window.name + ': I\'m closing')">
<B>Some numbers</B>
<UL><LI>one
<LI>two
<LI>three
<LI>four</UL>
</BODY>
</HTML>
See also the example for the Frame object.
Property. The window property is a synonym for the current window or frame.
1. window.propertyName
2. window.methodName
propertyName is the length or name property when the calling window refers to a Frame object.
methodName is any method associated with the window object.
Frame object, window object
The window property refers to the current window or frame.
The window property is read-only. The value of the window property is
<object nameAttribute>
<A HREF=""
onClick="this.href=pickRandomURL()"
onMouseOver="window.status='Pick a random URL' ; return true">
Go!</A>
self property
Method. Writes one or more HTML expressions to a document in the specified window.
document.write(expression1 [,expression2], ...[,expressionN])
window2=window.open('','window2')
beginComment="\<!--"
endComment="--\>"
window2.document.write(beginComment)
window2.document.write(" This some text inside a comment. ")
window2.document.write(endComment)
In Navigator 3.0, users can print and save generated HTML using the commands on the File menu.
To view HTML code that was generated with JavaScript write and writeln methods, the user must specify the view-source: protocol. If the user chooses Document Source or Frame Source from the View menu, the content displayed is that of the wysiwyg: URL. The following example shows a view-source: URL:
view-source:wysiwyg://0/file:/c|/temp/genhtml.html
For information on specifying the view-source: protocol in the location object, see the location object.
var mystery = "world"
// Displays Hello world testing 123
msgWindow.document.write("Hello ", mystery, " testing ", 123)
//Displays Hello world...
msgWindow.document.write
(mystr = "Hello " + "world...")
msgWindow.document.write(status = (age >= 18) ? "Adult" : "Minor")
close (document object), open (document object), writeln methods
document.writeln(expression1 [,expression2], ...[,expressionN])
All the examples used for the write method are also valid with the writeln method.
close (document object), open (document object), write methods
file: /Techref/language/JAVA/script/ref_t-z.htm, 118KB, , updated: 2009/2/2 13:27, local time: 2025/1/26 16:03,
3.144.100.197:LOG IN
|
©2025 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/Techref/language/JAVA/script/ref_t-z.htm"> taint </A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Ashley Roll has put together a really nice little unit here. Leave off the MAX232 and keep these handy for the few times you need true RS232! |
.