📅  最后修改于: 2020-10-25 11:20:04             🧑  作者: Mango
以下是一些内置函数,这些函数在Ext JS中大量使用。
此类检查您使用的平台,是电话还是台式机,mac或Windows操作系统。这些是与Ext.is类有关的以下方法。
Sr.No | Methods & Description |
---|---|
1 |
Ext.is.Platforms This function returns the platform available for this version. For example, when you run the following function, it returns something like this − [Object { property = "platform", regex = RegExp, identity = "iPhone"}, Object { property = "platform", regex = RegExp, identity = "iPod"}, Object { property = "userAgent", regex = RegExp, identity = "iPad"}, Object { property = "userAgent", regex = RegExp, identity = "Blackberry"}, Object { property = "userAgent", regex = RegExp, identity = "Android"}, Object { property = "platform", regex = RegExp, identity = "Mac"}, Object { property = "platform", regex = RegExp, identity = "Windows"}, Object { property = "platform", regex = RegExp, identity = "Linux"}] |
2 |
Ext.is.Android This function will return true, if you are using Android operating system, else it returns false. |
3 |
Ext.is.Desktop This function will return true, if you are using a desktop for the application, else it returns false. |
4 |
Ext.is.Phone This function will return true, if you are using a mobile, else it returns false. |
5 |
Ext.is.iPhone This function will return true if you are using iPhone, else it returns false. |
6 |
Ext.is.iPod This function will return true, if you are using iPod, else it returns false. |
7 |
Ext.is.iPad This function will return true, if you are using an iPad, else it returns false. |
8 |
Ext.is.Windows This function will return true, if you are using Windows operating system, else it returns false. |
9 |
Ext.is.Linux This function will return true, if you are using Linux operating system, else it returns false. |
10 |
Ext.is.Blackberry This function will return true, if you are using Blackberry, else it returns false. |
11 |
Ext.is.Mac This function will return true, if you are using Mac operating system, else it returns false. |
顾名思义,此类提供了有关浏览器/设备的当前环境是否支持该功能的信息。
Sr.No | Methods & Description |
---|---|
1 |
Ext.supports.History It checks if the device supports HTML 5 history as window.history or not. If the device supports history, then it returns true, else false. |
2 |
Ext.supports.GeoLocation It checks if the device supports geolocation method or not. Internally it checks for navigator.geolocation method. |
3 |
Ext.supports.Svg It checks if the device supports HTML 5 feature scalable vector graphics (svg) method or not. Internally it checks for doc.createElementNS && !!doc.createElementNS( “http:/” + “/www.w3.org/2000/svg”, “svg”).createSVGRect. |
4 |
Ext.supports.Canvas It checks if the device supports HTML 5 feature canvas to draw method or not. Internally it checks for doc.createElement(‘canvas’).getContext and returns a value based on the output of this method. |
5 |
Ext.supports.Range It checks if the browser supports document.createRange method or not. |
Ext.String类具有使用字符串数据的各种方法。最常用的方法是编码解码,修剪,切换,urlAppend等。
编码解码函数-这些是Ext.String类中提供的用于编码和解码HTML值的功能。
Sr.No | Methods & Description |
---|---|
1 |
Ext.String.htmlEncode This function is used to encode html value to make it parsable. Example − Ext.String.htmlEncode("< p > Hello World < /p >"); Output - "< p > Hello World < /p >". |
2 |
Ext.String.htmlDecode This function is used to decode the encoded html value. Example − Ext.String.htmlDecode("< p > Hello World < /p >"); Output - "< p > Hello World < /p >" |
3 |
Ext.String.trim This function is to trim the unwanted space in the string. Ext.String.trim(' hello '); Output – "hello" |
4 |
Ext.String.urlAppend This method is used to append a value in the URL string. Example − Ext.String.urlAppend('https://www.google.com' , 'hello'); Output - "https://www.google.com?hello" Ext.String.urlAppend('https://www.google.com?index=1' , 'hello'); Output – "https://www.google.com?index=1&hello" |
5 |
Ext.String.toggle This function is to toggle the values between two different values. Example − var toggleString = 'ASC' toggleString = Ext.String.toggle(a, 'ASC', 'DESC'); Output – DESC as toggleString had value ASC. Now again, if we print the same we will get toggleString = “ASC” this time, as it had value 'DESC'. It is similar to ternary operator toggleString = ((toggleString =='ASC')? 'DESC' : 'ASC' ); |
Sr.No | Methods & Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 |
Ext.userAgent() This function gives information about browser userAgent. UserAgent is to identify the browser and the operating system to the web server. Example − If you are working in Mozilla, it returns something like: “mozilla/5.0 (windows nt 6.1; wow64; rv:43.0) gecko/20100101 firefox/43.0” |
||||||||||||||
2 |
Version related function This function returns the version of the browser currently in use, if the function is called related to IE. In Firefox browser, it returns 0. These functions are Ext.firefoxVersion, Ext.ieVersion, etc. Example − If you are using Firefox browser and you call the method Ext.ieVersion for fetching the version of IE, then it returns 0. If you are using the same method in IE browser, then it will return the version you are using such as 8, 9, etc. |
||||||||||||||
3 |
Ext.getVersion() This function returns the current Ext JS version in use. Example − If you call Ext.getVersion(), it returns an array of values such as version, short version, etc. Ext.getVersion().version returns the current version of Ext JS used in the program, such as “4.2.2″. |
||||||||||||||
4 |
Browser related functions These functions return Boolean values based on the browser in use. These methods are Ext.isIE, Ext.isIE6, Ext.isFF06, and Ext.isChrome. Example − If you are using Chrome browser, then the function Ext.isChrome will return true all, otherwise it will return false. |
||||||||||||||
5 |
Ext.typeOf() This function returns the datatype of the variable. Example − var a = 5; var b = 'hello'; Ext.typeOf(a); Output – Number Ext.typeOf(b); Output - String |
||||||||||||||
6 |
DataType related methods − These functions return boolean value based on the datatype of the variable Example − var a = ['a', 'bc']; var b = 'hello'; var c = 123; var emptyVariable; var definedVariable; function extraFunction(){return true;}
|