While attempting to build a website, i have gone through many online tutorials. Thanks to those websites and stackoverflow, i got things up and running. However, out of curiosity, when i checked the source of other professional websites, the scripting looks so much more complex. I have listed a few examples here:
-
Im using XML in my web and i read from a web tutorial website that in order to manipulate the xml data using javascript, we first need to convert the xml doc to a DOM object, using code snippets like this:
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","books.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
I have checked several professional websites that use xml, but i don’t see such codes there. Could they have hidden the codes in some external file?
-
In another website, when i checked the source, it uses a lot of funny values such as this:
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="vDzFWVcOVLrtEQSDGPTcYv1RQRqWyN+jKq3DtdY1Q95kqTQ36 .......
What does all this mean? and why is it necessary to have this?
- Another one that i often see in professional websites is something called “google-analytics”. What is that?
My website is working perfectly fine, but im afraid that i might be missing out on something which i may not be aware of. Pls help me with this. Thanks a lot!
Your first code block that starts with
if (window.XMLHttpRequest)is cross-browser code for doing an Ajax call (a request for data from a remote server). This type of code would typically be in an external javascript file (which can be more appropriately cached by the browser across all the pages of your site). If you use a client-side framework like YUI or jQuery, this type of code will be in that framework. You would only need this code if you were doing ajax calls in your web page.The funny variable names are probably something generated server side by some server-side framework. It is unlikely a human would manually make names like that in manually created HTML. The names make sense to the server-side framework – they aren’t something you need to emulate.
Google-Analytics is a visitor tracking and site reporting tool that Google provides. A quick search on Google give you as much info as you want.