Saturday, 15 June 2013

html - Change img size with javascript in URL -


I want to resize an image with javascript according to URL,

I mean If the URL is:

mywebsite.com/something.hmtl?width=400&hight=250

Image is 400x250

And if the URL is

mywebsite.com/something.hmtl?width=300&hight=150

The image size is 300x150 < P> How do I do this with html and javascript? Thank you very much

You can get the parameter like this:

 < Code> parameter = Location.search.substr (1) .split ('& amp;') for dimentions = {} (in the parameter) {attr = params [i] .split ('=') if (attr [ 0] == '[0] ==' height ') {dimmed [etter [0]] = parseint (atrir [1])}} img = document. ITAlmentBitagnam ('IMG') [0] // You will find img.setAttribute ('width', dimension ['width']) img.setAttribute ('height, dimension [' height ']) before the page.   

No comments:

Post a Comment