1

I'm working on a small project where if the user enters the Konami code on a site, a filter is applied to every element (for now, will be better in the final version). Right now I have:

    <script type="text/javascript">
        var success = function() {
            var css = 'div { -webkit-filter: blur(10px); }',
                head = document.getElementsByTagName('head')[0],
                style = document.createElement('style');

            style.type = 'text/css';
            if (style.styleSheet){
                style.styleSheet.cssText = css;
            } else {
                style.appendChild(document.createTextNode(css));
            }
        }
        var konami = new Konami(success);
    </script>

and I'm using http://snaptortoise.com/konami-js/ which has successfully run when used with a redirect instead of a function (documentation says I can create a new Konami with the method shown above, or with a url string to be used as a redirect).

I've gotten javascript alert messages to show, but cannot implement this filter. What did I do wrong?

3 Answers 3

2

Keep the class in your stylesheet:

.blurred {
    -webkit-filter: blur(10px);
}

And then add it to your <body> tag:

var success = function() {
    document.body.className = 'blurred';
};
Sign up to request clarification or add additional context in comments.

Comments

2

You never append style to the head:

head.appendChild(style);

http://jsfiddle.net/ExplosionPIlls/2mTJf/

Comments

0

You need to add head.appendChild(style).

JS Fiddle http://jsfiddle.net/NMetj/

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.