Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set desktop background image with JavaScript

Tags:

javascript

Is it possible to set the desktop background image using JavaScript? I'm pretty sure it's not possible but I thought I would check.

If it isn't possible, is there any way for it to be done from the page?

like image 553
William Hurst Avatar asked Jan 26 '10 15:01

William Hurst


People also ask

How To set a background image with JavaScript?

When you want to change a webpage background image using JavaScript, you can do so by setting the background image of the document object model (DOM) property. The property you need to manipulate for changing the background image of the whole page is document. body. style.

How do you code a background in JavaScript?

background = "url('[INSERT HTTPS IMAGE URL HERE]')"; Note that the quotation marks are required around the url statement. This also works with . backgroundImage .


2 Answers

If that was possible, it would be a serious security issue. Many browser allow the user to right-click an image and select "use as wallpaper" or something similar.

like image 162
Jacob Rask Avatar answered Oct 03 '22 09:10

Jacob Rask


No, this is not possible (without a browser plugin).

You should just write instructions to the user for how to set an image as their wallpaper.

like image 25
Aistina Avatar answered Oct 03 '22 08:10

Aistina