ContactInformation
In this project, you’ll use a conditional statement to check forbrowser support of the HTML5 placeholder feature, and execute codeto replicate this feature if the condition returns a flasyvalue.
Within the (script) section you created in the previous step,enter the following function:
function insertPlaceholders() {
if(!Modernizr.input.placeholder) {
document.getElementById(“nameinput”).value =
“first and lastname”;
document.getElementById(“emailinput”).value =
“address@example.com”;
document.getElementById(“phoneinput”).value =
“###-###-####”;
}
}
This code references the placeholderproperty of the input property of the Modernizr object. TheModernizr library, which is linked to this document, is commonlyused on the web to enable developers to create the same or similarexperiences on both modern and older browsers. When a webpage that uses Modernizr is opened in a browser, the libraryqueries the browser to determine if it supports specific featuresused by the site.
Below the code for the function, add the followingbackward-compatible event listener to call the function when thewindow finishes loading:
if (window.addEventListener) {
window.addEventListener(“load”, insertPlaceholders, false);
} else if (window.attachEvent) {
window.attachEvent(“onload”, insertPlaceholders);
}
The text:
Hands-on Project 3-2
<(script)src="modernizr.custom.58072.js"><(/script)>
<(script)>
<(/script)>
3.29 Rating (146 Votes )
There are 3 Steps involved in it
It looks like youre working on a project to check for browser support of the HTML5 placeholder featu... View full answer
Get step-by-step solutions from verified subject matter experts