javascript
使用JavaScript中的示例的escape()函数
While transferring the data over the network or sometimes while saving data to the database, we need to encode the data. The function escape() is a predefined function in JavaScript, which encodes the given string.
在通過網絡傳輸數據或有時將數據保存到數據庫時,我們需要對數據進行編碼。 函數escape()是JavaScript中的預定義函數,可對給定的字符串進行編碼。
It encodes almost all special characters including spaces.
它幾乎編碼所有特殊字符,包括空格。
Note: escape() function does not encode some of the special characters like @+-/.*_
注意: escape()函數不會編碼某些特殊字符,例如@ +-/。* _
Example:
例:
<html> <head> <title>JavaScipt Example</title> </head><body><script>str = "Hello world!";//Actual stringdocument.write("Actual string is: " + str);document.write("<br>");//encoded stringdocument.write("Encoded string is: " + escape(str));document.write("<br>");//assign another stringstr = "email id: [email?protected]";//Actual stringdocument.write("Actual string is: " + str);document.write("<br>");//encoded stringdocument.write("Encoded string is: " + escape(str)); </script> </body> </html>Output
輸出量
Actual string is: Hello world! Encoded string is: Hello%20world%21 Actual string is: email id: [email?protected] Encoded string is: email%20id%3A%[email?protected]翻譯自: https://www.includehelp.com/code-snippets/escape-function-with-example-in-javascript.aspx
總結
以上是生活随笔為你收集整理的使用JavaScript中的示例的escape()函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java calendar_Java C
- 下一篇: gradle idea java ssm