Script textProperty

Script 对象参考手册Script Object

Example

Get the content of the <script> element:

var x = document.getElementById("myScript").text

xOutput:

document.write("Hello World!");

Try it Yourself »

Definition and Usage

The text property sets or returns the content of the <script> element.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the text property.


Syntax

Return the text property:

scriptObject.text

Set the text property:

scriptObject.text=contents

Property Values

Value Description
contents Specifies the content of the script.

Technical Details

Return Value: A string representing the content of the script. Returns the content of all child text nodes of the <script> element (other nodes, such as comments or elements, are ignored).


More Examples

Example

Another example - get the content of the <script> element:

var x = document.getElementById("myScript").text

xOutput:

var fruits = ["Banana", "Orange", "Apple", "Mango"]; function fruitFunction() { fruits.pop(); var x = document.getElementById("fruitdemo"); x.innerHTML=fruits; }

Try it Yourself »

Script 对象参考手册Script Object

Other Extensions