While CSS validating one of my sites this morning I happened to read the instructions and they are so much easier to implement…
Before I had a hard-coded link to the Jigsaw.w3.org validation service utility and had to specify the source page for every page. Now a common link to the Jigsaw validation URL is all that is necessary and the intuitive validation page now checks and inserts the following parameter:
$_SERVER[ 'HTTP_REFERER' ] ;
Give it a try by copying this common link to all your online web-pages:
Title: Just discovered that CSS validation has been made even easier
Above was the previous named PHP Topic.
The new script fails if the web-page contains JavaScript
I have to revert to this handy PHP utility which can be included in every web page. The utility supplies links to the w3.org validation utilities and eliminates the need to hard code the relevant web page URLs. It is very handy when developing and saves a lot of copying and pasting.
Eventually got round to testing and unfortunately unable to get it to work. Problem seems to be the curly brackets. I tried with, without, double curly brackets, all without success
You put the script before the code. You shouldn’t worry about what that validator says. I would just forget it exists, it’s really not useful in the slightest.
Your error is in the console.
(index):55 Uncaught TypeError: Cannot read property 'setAttribute' of null
at updatePathname ((index):55)
at (index):58
This says your reference to .fll a and .flr a are bad, and they are bad because they come before the elements are rendered.
The validator’s complaining because your source code URL contains non-URL characters ({ and }).
If you replaced the curly braces with square brackets (in both the URL and the javascript), the validator should stop its complaining (though if you want to be 100% compliant, you may want to URLEncode the ‘pathname’ you’re sticking in there…)
Each site and nearly every web-page includes the common “/var/www/footer.php” script
Regardless of which web-page is rendered the dynamic footer.php script generates two validation links in the footer.
Each validation link has the correct web-page URL to W3.org tools
This saves:
a, opening the W3,org validation page
b. copying the web-page URL
c. pasting the web-page URL into the w3.org validation page
Upon reflection I think it would be better to have an individual footer for each web-page and only include the /var/www/footer.php if isset($_GET['show-footer']) is true. Also the /var/www/footer.php could be an overlaid iFrame.
[off-topic]
Shall I rename this Topic to JavaScript Challenge? [/off-topic]
Really? It works fine here, even though “warning” appears in several other places in the URL.
var url = "https://jigsaw.w3.org/css-validator/validator?uri=warning&profile=css3svg&usermedium=all&warning=1&vextwarning=&lang=en";
// uri=warning should be changed to uri=http://example.com
// a possible conflict is that warning in other parts might get replaced instead.
url = url.replace("warning", "http://example.com");
// this works correctly, only replacing the first "warning" that it finds.
console.log(url);
Even though it works, it can be confusing to understand. Which is why I used a meaningful term of pathname, and curly braces with {pathname} to make it clearly obvious that it’s a template replaceable term.
var url = "https://jigsaw.w3.org/css-validator/validator?uri={pathname}&profile=css3svg&usermedium=all&warning=1&vextwarning=&lang=en";
// uri={pathname} should be changed to uri=http://example.com
url = url.replace("{pathname}", "http://example.com");
console.log(url);