Posts

Showing posts from January, 2010

Date Time Information in Java Scripts

Date and Time in JavaScript The date object is very useful for obtaining the date and time on the client. It supports various methods, which return a specific value. To start working with dates and time, we first initialize a variable and assign it a value with the new operator and the Date() constructor. The main function of the new operator with Date() constructor is to create a new date object that is stored in the variable. Here is the code: var d = new Date(); Thus, variable d contains a new date object. We can now call the various methods of this date object. var t_date = d. getDate() ; // Returns the day of the month var t_mon = d. getMonth() ; // Returns the month as a digit var t_year = d. getFullYear() ; // Returns 4 digit year var t_hour = d. getHours() ; // Returns hours var t_min = d. getMinutes() ; // Returns minutes var t_sec = d. getSeconds() ; // Returns seocnds var t_mil = d. getMilliseconds ; // Returns Milliseconds Now we

Browser Behavior Information in Java Scripts

//////////////BROWSER DETECTION////////////////// These all programme are based on   navigator object  of Java Script.Which tell us every information about the client's browser /////////Alert user, depending on browser/////////////// CODE 1: <html> <head> <script type="text/javascript"> function detectBrowser() { var browser=navigator.appName var b_version=navigator.appVersion var version=parseFloat(b_version) if ((browser=="Netscape"||browser=="Microsoft Internet Explorer") && (version>=4))   {alert("Your browser is good enough!")} else   {alert("It's time to upgrade your browser!")} } </script> </head> <body onload="detectBrowser()"> </body> </html> ////////////////Detect the visitor's browser and browser version////////////// CODE 2: <html> <head> <script type="text/javascript"> var browser=navigator.appName var b_version=nav