# Change document.bgColor using JS

**URL:** <https://forum.kirupa.com/t/change-document-bgcolor-using-js/24785>\
**Category:** Uncategorized\
**Created:** [July 4, 2003, 6:39pm UTC](https://forum.kirupa.com/t/change-document-bgcolor-using-js/24785 "2003-07-04T18:39:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dunk](https://avatars.discourse-cdn.com/v4/letter/d/b4bc9f/32.png) [@dunk](https://forum.kirupa.com/u/dunk)\
**Post date:** [July 4, 2003, 6:39pm UTC](https://forum.kirupa.com/t/change-document-bgcolor-using-js/24785/1 "2003-07-04T18:39:37Z")

</div>

I’m using this code in the head of my file…

```auto
SCRIPT language="javascript" type="text/javascript">function changeColor(c){document.bgColor=c}

```

And this in the body to trigger a change in background color onClick…

```auto
A HREF.="#colours" onClick='changeColor("#950090")'">IMG SRC="flash.jpg"<./A>

```

Now, how do I go about putting this code into a flash animation so that a click of a button would change the HTML file’s background color. I’m guessing I need to use the FSCommand, but I’m not sure how? Any help would be much appreciated!

thanks,

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 4, 2003, 6:42pm UTC](https://forum.kirupa.com/t/change-document-bgcolor-using-js/24785/2 "2003-07-04T18:42:03Z")

</div>

Obviously, the HTML isn’t entirely correct. I couldn’t get it to show up without adding periods and removing some of the tag openers.
