共用方式為


SPHttpUtility.EcmaScriptStringLiteralEncode Method (String, TextWriter)

Returns an encoded version of the specified JavaScript and appends it to the specified output stream.

Namespace:  Microsoft.SharePoint.Utilities
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
Public Shared Sub EcmaScriptStringLiteralEncode ( _
    scriptLiteralToEncode As String, _
    output As TextWriter _
)
'Usage
Dim scriptLiteralToEncode As String
Dim output As TextWriterSPHttpUtility.EcmaScriptStringLiteralEncode(scriptLiteralToEncode, _
    output)
public static void EcmaScriptStringLiteralEncode(
    string scriptLiteralToEncode,
    TextWriter output
)

Parameters

  • scriptLiteralToEncode
    Type: System.String

    A string that contains the JavaScript to encode.

Remarks

This method escapes the following characters: '"','\'','\\','<','>','+','\n','\r','/','(',')','%','&' and the characters greater than 0x7F.

See Also

Reference

SPHttpUtility Class

SPHttpUtility Members

EcmaScriptStringLiteralEncode Overload

Microsoft.SharePoint.Utilities Namespace