1

I have been following the tips on Shopify Resources to ask my visitors for permission to use cookies as per the EU cookie law.

The coding works, but when I pass the coding supplied through the W3C Markup Validation Service it comes up with the following error

Error Line 25, Column 139: Attribute read_more not allowed on element script at this point. …-cookie/require-opt-in.js" read_more="doc/website_privacy_policy.pdf">

My coding is

<link rel="stylesheet" type="text/css" href="http://www.heartinternet.co.uk/eu-cookie/main.css"/>
<script type="text/javascript" src="http://www.heartinternet.co.uk/eu-cookie/support-opt-in.js"></script>
<script type="text/javascript" src="http://www.heartinternet.co.uk/eu-cookie/require-opt-in.js" read_more="doc/website_privacy_policy.pdf"></script>

I have tried moving the read_more attribute outside of the <script> tag by changing it to

<script type="text/javascript" src="http://www.heartinternet.co.uk/eu-cookie/require-opt-in.js">read_more="doc/website_privacy_policy.pdf";</script>

That didn't work as it didn't display the 'read more' link in the pop-up. I also tried putting it into a separate <script> block so changing the coding to

<link rel="stylesheet" type="text/css" href="http://www.heartinternet.co.uk/eu-cookie/main.css"/>
<script type="text/javascript" src="http://www.heartinternet.co.uk/eu-cookie/support-opt-in.js"></script>
<script type="text/javascript">read_more="doc/website_privacy_policy.pdf";</script>
<script type="text/javascript" src="http://www.heartinternet.co.uk/eu-cookie/require-opt-in.js"></script>

but that didn't work either. Again, the 'read more' link wasn't displayed.

Is there a way of passing the read_more variable into the require-opt-in.js file and be compliant with W3C Markup?

2 Answers 2

1

They don't seem to give you another option for passing the url. You could manually set the read more link changing the last script block (which is the one starting the widget) with one written yourself. For example:

<script type="text/javascript">
    "use strict";
    var showSplash = function(){
        HI.optInCookies.readMoreURL = "doc/website_privacy_policy.pdf";
        HI.optInCookies.showSplash();
    };
    if(document.body) {
        showSplash();
    } else {
        setTimeout(showSplash, 100);
    }
</script>

It would break if they change their api, but I don't see other option as their code for searching the read more url is looking at attributes named "read_more" in script blocks. You could change the code above to pass the read more url in the way that makes the most sense to you.

You can also try it in this fiddle.

Sign up to request clarification or add additional context in comments.

Comments

0

You could insert the script with JavaScript:

var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("src", "http://www.heartinternet.co.uk/eu-cookie/support-opt-in.js");
script.setAttribute("read_more", "doc/website_privacy_policy.pdf");
document.getElementsByTagName("head")[0].appendChild(script);

So the W3C Markup Validation Service will not detect it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.