Results 1 to 2 of 2

Thread: style.backgroundImage not working in IE

  1. #1
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default style.backgroundImage not working in IE

    still very new to Java but I'm trying to get the background image to change when clicknig a link and this code work in all browsers but IE. I have tried the suggestions that worked for you regards ;'s, any help would be awesome.

    var backImage = new Array();

    backImage[0] = "url(images/bg1.jpg)";
    backImage[1] = "url(images/bg2.jpg)";
    backImage[2] = "";

    function changeBGImage(whichImage){

    document.body.style.backgroundImage = backImage[whichImage];
    }

    //-->
    </script>
    <a href="javascript:changeBGImage(1)">Change</a>



    Cheers,

    Stalkio

  2. #2
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Got this working, please find the correct code below. Also please note that IE seems to not like large files for backgrounds? very annoying when other browsers don't have issues. Hope this helps.

    <script type="text/javascript">
    function changeStyleOak()
    {
    document.body.style.backgroundImage="url(images/backgrounds/natural.jpg)";
    }

    </script>
    .
    .
    .
    .
    <input type="button" onclick="changeStyleOak()" style="background-image:url(images/backgrounds/natural_oak.jpg);" />

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •