JavascriptJson array functionJavascript json arrayfunction array1dToJson(a, p) { var i, s = '['; for (i = 0; i < a.length; ++i) { if (typeof a[i] == 'string') { s += '"' + a[i] + '"'; } else { // assume number type s += a[i]; } if (i < a.length - 1) { s += ','; } } s += ']'; if (p) { return '{"' + p + .. Json array with javascriptJson script to add statesHow to create a array in json? By using the simple javascript function as below you can create a simple array in json var head = { "data" : [ { "name" : "Math", "place" : "Alaska" }, .. Encode string in javascriptHow to encode a string using javascriptEncode string in Javascript: Use escape() to encode a string in javascript. This function encodes special characters, with the exception of: * @ - _ + . / ... <script type="text/javascript"> document.write(escape("w3calculator.com - Web Master Resource!!!!!")); </script> Output: w3calculator.com%20-%20Web%20Master%20Resource%21%21%21%21%21 .. Advantages and disadvantages of ajaxImportance of AJAXAdvantages: 1. XMLHttpRequest - It is used for making requests to the non-Ajax pages. It supports all kind of HTTP request type. 2. IFrame - It can make requests using both POST and GET methods. It supports every modern browsers. It supports asynchronous file uploads 3. Cookies - In spite of implementation .. How to get domain name from urlDocument.domain to get urlTo get a domain name from url, use "document.domain". document.domain Output: info.w3calculator.com Just use "document.domain" to get domain name from url using javascript. .. How to sort an array in numerical orderFunction sorting an arrayTo sort an array in numerical order, use the function array.sort(). var myarray=[25, 101, 10, 33] myarray.sort() //Array now becomes [10, 101, 25, 33] The above code will see only the first number. So it returns the result as 10, 101, 25, 33 To Sort an array in numerical order or in ascending order var .. Edit webpage from browserEdit code with firefox browserThis code lets you edit any page/website in real-time . With Firefox, you can even edit and save the modified pages to your computer. javascript:document.body.contentEditable='true'; document.designMode='on'; void 0 .. How to find a domain in vulnerable to attack or notSpoffing websiteThis is a simple javascript code find whether your domain or website is vulnerable to attack or not. This JavaScript code's result should match with the server name, if they do not match then the server might be spoof. javascript:alert("The actual URL is:\t\t" + location.protocol + "//" + location.hostname + "/" .. Buzz internet explorerShake the ie browserJavascript Fun code to buzz Internet Explorer browser Just copy the below code and paste in the address bar of your IE browser and press enter. It will buzz or shake the IE browser untill you interrupt or click anywhere on the browser Javascript Fun code to buzz IE javascript:function flood(n) {if (self.moveBy) .. How to find datatype of variableTypeof() functionHow to find type of variable name? Javascript has a special function called typeof which prints the datatype of a variable. When you do code some time the error may be triggered because improper useage of datatype. In such scenario you can use the typeof function to the the data .. |