jackmoore / wheelzoom

A small script for zooming IMG elements with the mousewheel/trackpad.
http://www.jacklmoore.com/wheelzoom
MIT License
342 stars 95 forks source link

Image links that contain single quotation marks do not show #13

Closed othieno closed 9 years ago

othieno commented 9 years ago

Due to the way the background image is created

img.style.backgroundImage = "url('"+img.src+"')";

links with one or more single quotation marks (a valid non-encoded URI character) such as http://www.marsnjak.com/sergej/yemen/highres/402%20-%20Old%20San'a'.jpg will fail to show.

This is because the resulting concatenated string for such a URL is ill-formed url('http://www.marsnjak.com/sergej/yemen/highres/402%20-%20Old%20San'a'.jpg')

Notice how the URL string is truncated to http://www.marsnjak.com/sergej/yemen/highres/402%20-%20Old%20San.

The fix is trivial: changing the aforementioned statement to img.style.backgroundImage = 'url("'+img.src+'")';

should generate the intended string url("http://www.marsnjak.com/sergej/yemen/highres/402%20-%20Old%20San'a'.jpg")

jackmoore commented 9 years ago

Good catch, thank you.