MrKMW
MrKMW

Reputation: 21

javascript code to change clip rect settings

What I'm trying to accomplish is when the window is resized, the blurred image is resized as well. For some reason the code is not working. Can someone spot what is wrong and what I need to do to correct the code. Thanks.

/* ------- BLUR BEHIND MESSAGE HOLDER CONTAINER SETTINGS ------- */

img.clipphoto { 
    /*--- CLIP SETTINGS: top, right, bottom, left ---*/
    clip: rect(18px,770px,600px,240px);

    position: absolute;
        -webkit-filter: blur(10px); 
        -moz-filter: blur(10px); 
        -o-filter: blur(10px); 
        -ms-filter: blur(10px); 
        filter: blur(10px);

    }

Upvotes: 1

Views: 160

Answers (2)

vogomatix
vogomatix

Reputation: 5061

Believe the values should be comma separated, not space separated

var clipString = "rect(" + t + "px," + r + "px," + b + "px," + l + "px)";

document.getElementsByClassName('clipphoto')[0].style.clip = clipString;

Edit: incorporated class accessor errror by Paul Roub too

Upvotes: 0

Paul Roub
Paul Roub

Reputation: 36448

There is no getElementByClassName() function. It's getElementsByClassName() (plural).

And you want the string "clipphoto", not the (non-existant) variable named clipphoto:

var clipString = "rect(" + t + "px, " + r + "px, " + b + "px, " + l + "px)";
document.getElementsByClassName('clipphoto')[0].style.clip = clipString;

Upvotes: 1

Related Questions