// Demonstrates window properties 'innerWidth' and 'innerHeight'
example1a.innerText = "Browser window width is: " +window.innerWidth +"px";
example1b.innerText = "Browser window height is: " +window.innerHeight +"px";
// Run the example again after adjusting your screen size
Click button to show result...
// Demonstrates open() method. Parameter is web address.
window.open("https://www.ontariolearn.com/");
Click button to open a new window...
// Demonstrates screen colorDepth property
example3a.innerText = "Your screen's color depth is: " +screen.colorDepth;
Click button find your screen's color depth:
// Demonstrates various document methods which open a new page, replace and write contents, change background color
document.open("text/html","replace");
document.write("<h2>Learning about the HTML DOM is fun! <h2>");
// bgColor will change the background color of a page
document.bgColor = "red";
document.close();
Click button to show result...
// HTML5 spcification adds geolocation property to navigator
// getCurrentPosition method is passed a callback function 'success'
navigator.geolocation.getCurrentPosition(success);
function success(position) {
// This function is called by getCurrentPosition(sucess)
// Gets your latitude and longitude coordinates
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
example5a.innerText = "Your latitude is: " +latitude;
example5b.innerText = "Your longitude is: " +longitude;
}
Click button to show result...
// Demonstrates appName property which returns the name of the browser and appCodeName property which returns the code for the browser
// Many browsers return the name "Netscape"
example6a.innerText = "Your broswer is: " +navigator.appName;
example6b.innerText = "Application code name of the browser: " +navigator.appCodeName;
Click button to show result...
// Demonstrates properties platform and language
example7a.innerText = "Your broswer platform (operating system) is: " +navigator.platform;
example7b.innerText = "Broswer language is: " +navigator.language;
Click button to show result...
>
// Returns the width and height of the screen
example8a.innerText = "Screen width is: " +screen.width;
example8b.innerText = "Screen height is: " +screen.height;
// Returns the width and height less minus interface features like the Windows Taskbar
example8c.innerText = "Screen availWidth is: " +screen.availWidth;
example8d.innerText = "Screen availHeight is: " +screen.availHeight;
Click button to show result...
function historyExample1(){
// Demonstrates history object, back() method
window.history.back();
}
function historyExample2(){
// Demonstrates history object, go() method which accepts an argument for the number of pages to move
window.history.go(-2);
}