How to change background image (margin image) through script when entering a room

I'm trying to change the background image/margin image when I load a new room.

I've tried doing what it says in the documentation:

JS.setCss("#gameBorder", "background-image:url(" + GetFileURL("space.png") + ");")

And then I replaced #gameBorder to body:

JS.setCss("body", "background-image:url(" + GetFileURL("space.png") + ");")

However, neither of these js script commands set the CSS for the background image, for either the body tag or the #gameBorder id.
I did try changing the background-color on the body, and it worked, but for some reason, the background-image property does change at all.

Help?


You can try this

JS.eval("$('body').css('background-image', 'url(" + GetFileURL("space.png") + ")');")


(The reason for this problem is that the setCss function doesn't work with values containing a colon, such as URIs)


Just guessing, but try this...
Change the background in the UI, then switch to code view, find the command that changes the background, and edit that to the picture you want.
It may be easier to try this with a new game with nothing else added.


Thank you for the switching to code view advice! I think I might try that, myself, with crossed fingers, at any rate.


Sorry for the late response, but I will try all of those answers. Thank you!


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums