Validating Pages

When creating your pages, it’s a great idea to make sure that you’re making sites that adhere to Web standards; such pages load quicker in modern browsers and are easier to maintain. The easiest way to check a page that you’re working on for valid code is by running it against the page validator maintained by the World Wide Web Consortium (W3C), at http://validator.w3.org. This bookmarklet, Script 17.13, checks the page currently shown in your browser for validity. It does this by taking the URL of the current page, passing it to the validator, and then opening a new window with the validator’s results, as shown in Figure 17.28.

Figure 17.28. Running your page against the W3C validator returns this happy result, if you’ve written your page correctly.


To validate your pages:

  • window.open('http://validator.w3.org/check?uri='+window.location.href,'','width=800,height=900, resizable=yes,scrollbars=yes'),

    This one, useful as it is, isn’t exactly rocket science. First, we open a window and pass that window the URL to the validator. You’ll note the validator has a parameter, uri, which accepts the URL of the current page, which we pass as location.href. The plus sign between the two concatenates the location object to the validator’s URL. The rest of the line is just parameters for the window’s size and other attributes.

    Script 17.13. Use this script to make sure your pages contain Web-standard, valid markup.
    javascript:(function(){window.open('http://validator.w3.org/check?uri='+location.href,'','width=800,height=900,resizable=yes,scrollbars=yes'),})();

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.3.122