View Full Version : What's the code to "set image as background" (and other Q's)

07-10-2004, 12:37 AM
when you right click on any image (atleast in I.E), you have the option to "set as background". I'd like to be able to have a slideshow, and have a button users could click that would effectively "Set the current image as background". What would the JS code be for that?

on a tangent (if this should be in a seperate thread, let me know):
I assume that i'd need to have each image appear in some sort of an image placeholder (unless i want a billion .html files... which i do not *shakes fist at Lemming*). Knowing this, how would i link the current image as the background image if they are appearing dynamically on the page?

aswell, I'm prepared to name my pictures in a way that a counter may be used to show each one without having to hardcode each image name in (ex: 1.jpg, 2.jpg, etc)... if that would make life easier.

Lastly... the image shown on the screen will be a somewhat shrunken version of the image. Does anyone know of a script i can use to take a larger image and have it show... say 4x smaller (while keeping the proportions). This would avoid me having to make a second copy of each pic, and have the "Set image as background" linking to the larger version...

Thanks... lemme know if i should chop it up into 3 seperate threads. it's one endeavor, thats why i put it all here.


07-12-2004, 04:47 AM
anyone, anything? ... I'll be your best friend.

well, okay, maybe not... but it worked years ago :)

07-12-2004, 11:55 PM
no one seems to want to touch this thread....

okay, i'll repost later i guess

Willy Duitt
07-13-2004, 12:21 AM
I'm sure the reason noone has responded is because your whole premise of changing the users desktop image is as intrusive as changing their homepage....

And before you come back and state that your intention is not to be intrusive. Let me point out that if you were given the script, anyone could source your page, grab the script and change the event handler from onclick on a button to onload, onmouseover or onscroll would not be far behind and the script would soon be exploited....

In regards to counters involving sequentially named images, either search this forum for several such scripts I have recently posted or, I believe there is one which was posted in the Post a Javascript forum...

In regards to providing a thumbnail image 1/4 the size of the original. The purpose of making second and completely seperate thumbnail images is to avoid users having to download a large byte image for merely previewing. But if you wish to do this. Define and divide either the height or width by 4 in your image tags. If only one property size is defined, the image will resize proportionally....


07-13-2004, 10:04 PM
i see your point about the exploitability of the background image script, so here's what i'm going to do. I'm going to outline the application, and you tell me if its still an issue (which it will be, but perhaps a contained one).

i have a bunch of very nice backgrounds that friends, coworkers, etc all love and subsequently ask for. as it stands now i have them all in a .zip file, and when one is needed i download the entire thing. not a problem as such, but alot of these people dont know how to set images as backgrounds in the first place... which in turn means that i get asked to "come over, and oh yeah, switch the background to another cool one".

I want to avoid these outings in the future by setting up a PRIVATE url (not linked to, just given out in person) where my friends et. al can view the entire collection and just click a button to set it as their background (stretched).

if you think that this is still too much of a risk, i can encrypt my source code. barring that, whoever takes the time to steal and decrypt it could probably just as easily write the code themselves.

point being, if you still think it's too hazardous... thats okay, i wont pursue it. i just wanted you to know the exact purpose of this before you judged it.

Willy Duitt
07-13-2004, 10:26 PM
That functionality is already present on the browser right click context menu. In IE it is Set as Background and Mozilla it is Set as Wallpaper, and although I'm too lazy to open and check Netscape, I'm sure it is there also....

Simply post a page with your thumbnails (and perhaps a full size popup) and include the instructions on how to right click and set as.....

Other than that, I do not know what to tell you because I'm certainly not showing you how to exploit this and I doubt anyone else will either....


07-14-2004, 04:19 PM

probably a good thing.