hellouthere Posted July 1, 2008 Share Posted July 1, 2008 I'm trying to change a style using javascript, its all working ok except changing a background image in ie6... hellouthere.homelinux.com/eanda The site uses AJAX to navigate, on each page the image below the logo should be updated, this works well in FF IE7 and Safari but previous to IE7 all the AJAX works except the updating the image on each page. I'm using AJAx but I think this is a pure javascript problem as everything works fine in other browsers. I know IE6 is a pain but is there any workaround to get this to work? This is the function to change the text and image for each page... it updates the background image of the pic1 div and adds the correct text to the required div (objID). function navto(serverPage, objID) { document.getElementById("pic1").style.backgroundImage = "url(images/" + serverPage + ".png)"; var obj = document.getElementById(objID); xmlhttp.open("GET", serverPage + ".inc"); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { obj.innerHTML = xmlhttp.responseText; } } xmlhttp.send(null); } When the homepage opens it uses this function to load the image and text and that works fine, its when it comes to changing to other pages that it fails... Thanks in advance Quote Link to comment Share on other sites More sharing options...
hellouthere Posted July 1, 2008 Author Share Posted July 1, 2008 if this is an ie6 problem and i cant do anything could someone let me know please Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 1, 2008 Share Posted July 1, 2008 i was able to get it working if I opened the image ahead of time in my browser...try preloading the image: function navto(serverPage, objID) { var img = new Image(); img.src = "images/" + serverPage + ".png"; document.getElementById("pic1").style.backgroundImage = "url(images/" + serverPage + ".png)"; Quote Link to comment Share on other sites More sharing options...
hellouthere Posted July 1, 2008 Author Share Posted July 1, 2008 Worked a treat! Thanks very much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.