VOOZH about

URL: https://www.geeksforgeeks.org/html/html-dom-script-charset-property/

⇱ HTML DOM Script charset Property - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML DOM Script charset Property

Last Updated : 15 Jun, 2023

The HTML DOM Script charset property is used to set or return the value of a charset attribute of an <script> element. The charset attribute is used to specify the character encoding used in an external script.

Syntax: 

  • It returns the charset property.  
scriptObject.charset
  • It is used to set the charset Property. 
scriptObject.charset = charset 

Property Values: It contains single value charset which specifies the character encoding used in an external script. 

  • "ISO-8859-1": It is used to specify the standard encoding for the Latin alphabet.
  • "UTF-8": It is used to specify the character encoding for Unicode. Compatible with ASCII.

Return Value: It returns a string value that represents the character encoding of the script element. 

Example: This example illustrates how to return the script charset property. 

Output: 

👁 Image
 

Example 2: This example illustrates how to set the script charset property. 

Output: 

👁 Image
 

Supported Browsers: The browsers supported by HTML DOM Script charset property are listed below: 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera
Comment