Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Javascript/HTML Create a Web page that uses the \"onload\" event and \"browser s

ID: 3733594 • Letter: J

Question

Javascript/HTML

Create a Web page that uses the "onload" event and "browser sniffing" to discover the following information: User's browser (IE - Chrome - Firefox - etc.) and browser version User's browser inner screen width and inner screen height (NOT including toolbars/scrollbars) Output When the page loads the following information should be written to the page based on the results of your browser sniffing: You are using version _________ of the ____________ browser to view this page in a browser whose inner window that is _____ pixels wide and _____ pixels tall. The first blank space in the line above represents the browser version The second blank space in the line above represents the browser name The third blank space in the line above represents the width of the viewer's browser's inner window in pixels The fourth blank space in the line above represents the height of the viewer's browser's inner window in pixels Search the Internet as needed

Explanation / Answer

Following is the javascript Code:

<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>
<p id="demo1"></p>

<script type="text/javascript">

function get_browser_info(){
var ua=navigator.userAgent,tem,M=ua.match(/(opera|chrome|safari|firefox|msie|trident(?=/))/?s*(d+)/i) || [];
if(/trident/i.test(M[1])){
tem=/rv[ :]+(d+)/g.exec(ua) || [];
return {name:'IE ',version:(tem[1]||'')};
}
if(M[1]==='Chrome'){
tem=ua.match(/OPR/(d+)/)
if(tem!=null) {return {name:'Opera', version:tem[1]};}
}
M=M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
if((tem=ua.match(/version/(d+)/i))!=null) {M.splice(1,1,tem[1]);}
return {
name: M[0],
version: M[1]
};
}

var browser=get_browser_info();


document.getElementById("demo").innerHTML =
"You are using version " + browser.version + " of the " + browser.name + " browser to view this page in a browser whose inner window that is " +window.innerWidth+ " pixels wide and " +window.innerHeight+" pixels tall";

</script>

</body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote