compuhelpindia.com

JavaScript HTML DOM Objects

Compuhelpindia.com
« Previous


This page teaches you how to find and access HTML Objects in an HTML page.
Date Objects
The easiest way to find objects in the DOM.
Eaxmple:
<!DOCTYPE html>
<html>
<script>
function date()
{
var d=new Date();
document.write("present date and timing="+d+"<br>");
document.write("present Hours="+d.getHours()+"<br>");
document.write("present Minutes="+d.getMinutes()+"<br>");
document.write("present Seconds="+d.getSeconds()+"<br>");
document.write("present Year="+d.getYear()+"<br>");
}
</script>
</head>
<body>
<p>Click Here And Show Date And Time</p>
<button onClick="date()">Click Here</button>
</body>
</html> 

Click Here And Show Date And Time

HTML Objects in javaScript.
The easiest way to find HTML objects in the DOM.

Example:
<!DOCTYPE html>
<html>
<script>
function myDom()
{
var a="Compuhelp";
var b="I am learing Javascript"
document.write("length of string="+a.length+"<br>");
document.write("Charactes at position="+a.charAt(10)+"<br>");
document.write("italic of string="+a.bold()+"<br>");
document.write("index="+b.indexOf('n')+"<br>");
document.write("Concat="+a.concat(b)+"<br>");
document.write("Italics="+a.italics()+"<br>");
document.write("Strike="+b.strike()+"<br>");
document.write("Font Color="+a.fontcolor('blue')+"<br>");
document.write("Font Size="+a.fontsize(6)+"<br>");
}
</script>
</head>
<body>
<p>Click Here And Show Font and text propertied</p>
<button onClick="myDom()">Click Here</button>
</body>
</html>  
 

Click Here And Show The Font and Text propertied

Math Objects
The easiest way to find objects in the DOM. Example:
<!DOCTYPE html>
<html>
<script>
function math()
{
document.write("Absolute="+Math.abs(-90)+"<br>");
document.write("Math Power="+Math.pow(2,3)+"<br>");
document.write("Math Maximal="+Math.max(2,5,9,7)+"<br>");
document.write("Math Minimum="+Math.min(3,8,5,11)+"<br>");
}
</script>
</head>
<body>
<p>Click Here and check Math Objects</p>
<button onclick="math()">Click Here</button>
</body>
</html>

Click Here and check Math Objects

Screen Objects
The easiest way to find objects in the DOM. Example:
<!DOCTYPE html>
<html>
<script>
function myScreen()
{
document.write("Screen Height="+screen.height+"<br>");
document.write("Screen Width="+screen.width+"<br>");
document.write("Screen Depth="+screen.colorDepth+"<br>");
}
</script>
</head>
<body>
<p>Click Here and check Screen Objects</p>
<button onclick="myScreen()">Click Here</button>
</body>
</html>

Click Here and check Screen Objects