Thursday, 5 April 2012

View Background Image in Opera/Chrome/IE with a javascript bookmarklet

Create a new book mark (preferably on your bookmarks bar or) wherever you choose within easy access, and then select and paste in all of this code as the URL/address:

javascript:var backup=document.body.onclick;void(document.body.onclick=function(event){var bodyStyle=window.getComputedStyle(document.body,null).getPropertyValue('background-image');var bgStyle=window.getComputedStyle(event.target,null).getPropertyValue('background-image');if(bgStyle!='none')window.open(bgStyle.replace(/url\("?/,'').replace(/"?\)$/,''));else if(bodyStyle!='none')window.open(bodyStyle.replace(/url\("?/,'').replace(/"?\)$/,''));document.body.onclick=backup;backup=undefined;});

To view any web page's background image, first click on the bookmark then click on the background image you wish to view.

It should work, amazingly well, if the page does have a background image!

Got it set up in IE9, Chrome18, Opera11, no probs

---

These steps are not necessary in Mozilla's Firefox browser, which already has an in-built "View Background Image" option on its right-click context menu.

But this just saves the hassle of having to copy a URL from Chrome/Opera/IE into Firefox just to view a background image.

Tip of the hat to MyOpera for the tip.

No comments:

Post a Comment