navigator

Views:
 
Category: Entertainment
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

Navigator object:

Navigator object Prof indrani sen,MCA,MPhil Computer Science

PowerPoint Presentation:

Browser detection is an important part of programming through javascript . It's fundamental that only relevant browsers pick up on your code. In this session we will learn the navigator object of JavaScript, and use it to perform browser detection, whether the subject is Firefox, Internet Explorer, Opera, etc. Prof indrani sen,MCA,MPhil Computer Science

PowerPoint Presentation:

Properties Description appCodeName The code name of the browser. appName The name of the browser ( ie : Microsoft Internet Explorer). appVersion Version information for the browser ( ie : 5.0 (Windows)). cookieEnabled Boolean that indicates whether the browser has cookies enabled. language Returns the default language of the browser version ( ie : en-US). NS and Firefox only. platform[] The platform of the client's computer ( ie : Win32). Prof indrani sen,MCA,MPhil Computer Science

PowerPoint Presentation:

systemLanguage Returns the default language of the operating system ( ie : en-us). IE only. userAgent String passed by browser as user-agent header. ( ie : Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1;) You can probe the userAgent property for mobile browsers such as iPhone , iPad , or Android ismobile The following variable returns true if the user is using one of the following mobile browsers: //returns true if user is using one of the following mobile browsers var ismobile = navigator.userAgent.match (/( iPad )|( iPhone )|(iPod)|(android)|( webOS )/ i ) userLanguage Returns the preferred language setting of the user ( ie : en-ca). IE only. Prof indrani sen,MCA,MPhil Computer Science

Code:

Code <html> <head> <script type="text/ javascript "> document.write ("<b>The App code of the browser:"+ navigator.appCodeName +"</b>< br >"); document.write ("<b>The Name of the browser:"+ navigator.appName +"</b>< br >"); document.write ("<b>The version of the browser:"+ navigator.appVersion +"</b>< br >"); Prof indrani sen,MCA,MPhil Computer Science

PowerPoint Presentation:

document.write ("<b>Are cookies enabled in this browser??"+ navigator.cookieEnabled +"</b>< br >"); document.write ("<b>The platform:"+ navigator.platform +"</b>< br >"); document.write ("<b>The language of the operating system:"+ navigator.systemLanguage +"</b>< br >"); Prof indrani sen,MCA,MPhil Computer Science

PowerPoint Presentation:

ismobile = navigator.userAgent.match (/( iPad )|( iPhone )|(iPod)|(android)|( webOS )/ i ); if( ismobile ) alert("user is using a mobile") else alert("user is using a PC/Laptop") </script> </head> <body bgcolor ="pink" text="black"> </body> </html> Prof indrani sen,MCA,MPhil Computer Science

History Object:

History Object The history object contains the URLs visited by the user (within a browser window). The history object is part of the window object and is accessed through the window.history property. Prof indrani sen,MCA,MPhil Computer Science

PowerPoint Presentation:

Property Description length Returns the number of URLs in the history list Method Description back() Loads the previous URL in the history list forward() Loads the next URL in the history list go() Loads a specific URL from the history list History Object Methods Prof indrani sen,MCA,MPhil Computer Science

History back() Method :

History back() Method The back() method loads the previous URL in the history list. This is the same as clicking the Back button . history.back () Prof indrani sen,MCA,MPhil Computer Science

History forward() Method :

History forward() Method The forward() method loads the next URL in the history list. This is the same as clicking the Forward button or history.go (1). history.forward () Prof indrani sen,MCA,MPhil Computer Science

Go() method:

Go() method The go() method loads a specific URL from the history list. The parameter can either be a number which goes to the URL within the specific position -1 goes back one page. 1 goes forward one page or a string. The string must be a partial or full URL Prof indrani sen,MCA,MPhil Computer Science

PowerPoint Presentation:

<html> <head> <script type="text/ javascript "> document.write ("<b>The total number of URLs visited by the browser:"+ history.length +"</b>< br >"); function load_prev () { window.history.back (); } Prof indrani sen,MCA,MPhil Computer Science

PowerPoint Presentation:

function load_next () { window.history.forward (); } function go_url () { var x=prompt("Enter the URL you want to visit?"); window.history.go (x); alert("visited url "); } Prof indrani sen,MCA,MPhil Computer Science

PowerPoint Presentation:

</script> </head> <body bgcolor ="pink" text="black"> <button type="button" onclick =" load_prev ()">Go to previous page</button> <button type="button" onclick =" load_next ()">Go to next page</button> <button type="button" onclick =" go_url ()">Visit URL</button> </body> </html> Prof indrani sen,MCA,MPhil Computer Science

The Location Object :

The Location Object The location object contains information about the current URL. The location object is part of the window object and is accessed through the window.location property. Prof indrani sen,MCA,MPhil Computer Science

PowerPoint Presentation:

Property Description host Returns the hostname and port of a URL hostname Returns the hostname of a URL href Returns the entire URL pathname Returns the path name of a URL port Returns the port number the server uses for a URL protocol Returns the protocol of a URL search Returns the query portion of a URL Prof indrani sen,MCA,MPhil Computer Science

Location host Property :

Location host Property The host property returns the hostname and port of a URL. location.host Prof indrani sen,MCA,MPhil Computer Science

Location hostname Property :

Location hostname Property The host property returns the hostname of a URL. location.hostname Prof indrani sen,MCA,MPhil Computer Science

Location href Property:

Location href Property The href property returns the entire URL of the current page. Prof indrani sen,MCA,MPhil Computer Science

Location pathname Property :

Location pathname Property The pathname property returns the path name of a URL. location.pathname Prof indrani sen,MCA,MPhil Computer Science

Location port Property:

Location port Property The port property returns the port number the server uses for a URL. <script type=" text / javascript "> document.write ( location.port ); </script> Prof indrani sen,MCA,MPhil Computer Science

Location protocol Property:

Location protocol Property The protocol property returns the protocol of the current URL, including the first colon (:). location.protocol <script type="text/ javascript "> document.write ( location.protocol ); </script> Prof indrani sen,MCA,MPhil Computer Science

PowerPoint Presentation:

Method Description assign() Loads a new document reload() Reloads the current document replace() Replaces the current document with a new one Location Object Methods Prof indrani sen,MCA,MPhil Computer Science

Location assign() Method :

Location assign() Method The assign() method loads a new document. location.assign ( URL ) Prof indrani sen,MCA,MPhil Computer Science

Location reload() Method :

Location reload() Method The reload() method is used to reload the current document. location.reload () Prof indrani sen,MCA,MPhil Computer Science

Location replace() Method :

Location replace() Method The replace() method replaces the current document with a new one. location.replace ( newURL ) Prof indrani sen,MCA,MPhil Computer Science

Screen Object :

Prof indrani sen,MCA,MPhil Computer Science Screen Object

PowerPoint Presentation:

Prof indrani sen,MCA,MPhil Computer Science Property Description availHeight Returns the height of the screen (excluding the Windows Taskbar) availWidth Returns the width of the screen (excluding the Windows Taskbar) colorDepth Returns the bit depth of the color palette for displaying images height Returns the total height of the screen pixelDepth Returns the color resolution (in bits per pixel) of the screen width Returns the total width of the screen Screen Object Properties

authorStream Live Help