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.
在通過網(wǎng)絡(luò)傳輸數(shù)據(jù)或有時(shí)將數(shù)據(jù)保存到數(shù)據(jù)庫(kù)時(shí),我們需要對(duì)數(shù)據(jù)進(jìn)行編碼。 函數(shù)escape()是JavaScript中的預(yù)定義函數(shù),可對(duì)給定的字符串進(jìn)行編碼。
It encodes almost all special characters including spaces.
它幾乎編碼所有特殊字符,包括空格。
Note: escape() function does not encode some of the special characters like @+-/.*_
注意: escape()函數(shù)不會(huì)編碼某些特殊字符,例如@ +-/。* _
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
總結(jié)
以上是生活随笔為你收集整理的使用JavaScript中的示例的escape()函数的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java calendar_Java C
- 下一篇: mysql安装注意步骤,mysql安装步