Jump to content

[SOLVED] Style change


hellouthere

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/112744-solved-style-change/
Share on other sites

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)";


Link to comment
https://forums.phpfreaks.com/topic/112744-solved-style-change/#findComment-579185
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.