compuhelpindia.com

JavaScript HTML DOM Document

Compuhelpindia.com
« Previous                                                                                                                                   Next Chapter »


This page teaches you how to find and access HTML Documents in an HTML page.
Bg color
Example:
<!DOCTYPE html>
<html>
<script>
function bgfunction()
{
document.bgColor="red";
}
</script>
</head>
<body>
<input type="button" value="Bg Color" onclick="bgfunction()" />
</body>
</html>
fg color
Example:
<!DOCTYPE html>
<html>
<script>
function fgfunction()
{
document.fgColor="red";
}
</script>
</head>
<body>
<input type="button" value="Bg Color" onclick="fgfunction()" />
</body>
</html>
Window Close
Example:
<!DOCTYPE html>
<html>
<script>
function win_colse()
{
window.close();
}
</script>
</head>
<body>
<input type="button" value="Bg Color" onclick="win_close()" />
</body>
</html>
Window Print
Example:
<!DOCTYPE html>
<html>
<script>
function printf()
{
window.print();
}
</script>
</head>
<body>
<input type="button" value="Print" onclick="printf()" />
</body>
</html>
Click The Button for window print.
Window Title
Example:
<!DOCTYPE html>
<html>
<script>
function Title()
{
document.title="Welcome To Compuhelp";
}
</script>
</head>
<body>
<input type="button" value="Title" onclick="Title()" />
</body>
</html>
Click The Button for window Title change.
Text Size Change
Example:
<!DOCTYPE html>
<html>
<script>
function Size()
{
document.getElementById("txt_1").size=30;
}
</script>
</head>
<body>
<input type="button" value="Title" onclick="Title()" />
</body>
</html>
Click The Button for text Size Change:
Text Value disabled-True,False
Example:
<!DOCTYPE html>
<html>
<script>
function mytrue()
{
document.getElementById("txt_2").disabled=true;
}
</script>
</head>
<body>
Fill The Value and Click The button:
<input type="text" id="txt_2" />
<input type="button" name="btn" value="click" onclick="mytrue()" />
</body>
</html>
                    And
<!DOCTYPE html>
<html>
<script>
function mytrue()
{
document.getElementById("txt_2").disabled=true;
}
</script>
</head>
<body>
Fill The Value and Click The button:
<input type="text" id="txt_2" />
<input type="button" name="btn" value="click" onclick="mytrue()" />
</body>
</html>
Fill The Value and Click The button of Disabled:
Click the button of Enabled: