random div background

Hello, I need some help getting a random background for a div. I found the following javascript below but it is not working. I want the image to change on page reload. What is wrong with the code?

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<title>Untitled page</title>
<style type="text/css">
#midimage {
     height: 400px;
     width: 400px;
     margin: 0px;
     padding: 0px;
     float: left;
     background-image: url(one.jpg);
       color: white;
<script type="text/javascript">
    var bgs = new Array('one.jpg', 'two.jpg', 'three.jpg', 'four.jpg');
    var colors = new Array('#000000', '#FFFFFF', '#CCCCCC', '#FF0000'); //Corresponds to the entry at the same position in the bgs array.
    function randomizeBG() {
        var el = document.getElementById('midimage');
        var i = Math.floor(Math.random() * bgs.length);
        var bg = "url(" + bgs[i] + ")";
        var col = colors[i];
        el.style.setProperty('background-image', bg, null);
        el.style.setProperty('color', col, null);


<div id="midimage">&nbsp;</div>
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You're not calling the function. Try the following:
<body onload="randomizeBG()">

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gogetsomeAuthor Commented:
Sorry, but that did not work. The page error message  = error: Object doesn't support this property or method.
gogetsomeAuthor Commented:
My bad, in fact it does work.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.