Answered! How do you do this on a web page? * Show the date and time when the a webpage loads and present this in…

How do you do this on a web page?

* Show the date and time when the a webpage loads and present this in a scrolling banner across the top of the web page

* Animate the background color of the web page

*Implement a button that presents an Alert dialog box that counts the number of times the character “a” is used on the page

Expert Answer

<!DOCTYPE html>
<html>
<head>
<script>
function getDate() {
var today = new Date();

document.getElementById(‘time’).innerHTML=today;

}
function getCount()
{
var str = document.getElementById(‘text’).innerHTML;
alert(“No of Times a occured is “+count(str,’a’))
}
function count(string,char) {
var re = new RegExp(char,”gi”);
return string.match(re).length;

}

</script>
<style>
.button {
position: absolute;
top: 50%;
}
.wrapper {
text-align: center;
}
</style>
</head>

<body onload=”getDate()” style=”background-color:powderblue;”>
<marquee BEHAVIOR=ALTERNATE bgcolor=”yellow”>
<i>
<font color=”blue”>
Today’s date is :
<strong>
<span id=”time”></span>
</strong>
</font>
</i>
</marquee>
<br/>
<br/>
<p id=”text”>This Is an Example</p>
<div class=”wrapper”>
<button class=”button” onclick=”getCount()”>Count</button>
</div>
</body>

</html>

Output:

Still stressed from student homework?
Get quality assistance from academic writers!