Page 1 of 1
works on mozzila, not on IE7
Posted: Fri Apr 13, 2007 8:10 am
by sarris
hi there. came up to a werid problem
i have this code
Code: Select all
houselist = document.getElementById("listdiv");
var house = document.createElement("table");
alert("1");
var htmlstring = '<tr><td width = "180">'+address+'</td><td width = "110">Type</td><td align = "center" width = "85" rowspan = "2"><b>'+size+' sq.m</b></td><td align = "center" width = "85" rowspan = "2"><b>'+price+' €</b></td><td align = "center" width = "130" rowspan = "3">Image Here</td></tr><tr><td><strong>'+area+'</strong></td><td>'+beds+' rooms</td></tr><tr><td>id: '+id+'</td><td><a href="javascript: closerLook('+id+')"><small>Closer Look onMap</small></a></td></tr>';
alert("2");
house.innerHTML = htmlstring;
alert("3");
on mozzila everything works ok
on IE7 alert 3 doesnt show...off course nothing else works after that.
anyone knows why?
Posted: Fri Apr 13, 2007 6:55 pm
by RobertGonzalez
Are you getting any Javascript errors in the browser?
Posted: Sat Apr 14, 2007 2:12 am
by sarris
Are you getting any Javascript errors in the browser?
no...however i never did
Posted: Sat Apr 14, 2007 10:08 am
by RobertGonzalez
Maybe try something like:
Code: Select all
if (house.firstChild) {
house.removeChild(house.firstChild);
}
house.appendChild(document.createTextNode(htmlstring));
Not saying it will work, but it might.
Posted: Sat Apr 14, 2007 2:54 pm
by sarris
i put your code and it went through alert 3 on
IE7[/b, BUT
now in mozzila the html code is not recognised. Instead of having html elements created (as it is happening allright with previous code and mozzila) it shows just the string Code: Select all
'<tr><td width = "180">'+address+'</td><td width = "120">Type</td><td align = "center" width = "85" rowspan = "2"><b>'+size+' sq.m</b></td><td align = "center" width = "85" rowspan = "2"><b>'+price+' €</b></td><td align = "center" width = "130" rowspan = "3">Image Here</td></tr><tr><td><strong>'+area+'</strong></td><td>'+beds+' rooms</td></tr><tr><td>id: '+id+'</td><td><a href="javascript: closerLook('+id+')"><small>Closer Look onMap</small></a></td></tr>';
on
IE7 it shows on the bottom of the page "Page Error" AND it doesnt show any of the elements of house object
any more thoughts on it??
thanks allready though
Posted: Sat Apr 14, 2007 4:14 pm
by RobertGonzalez
Does it show correctly in the alert prompt in Mozilla? How about Opera?
Posted: Sun Apr 15, 2007 12:06 pm
by sarris
with your code:
in both cases it shows the alerts.BUT
mozzila: show string instead of creating the rows and cells and indicated in the htmlstring
IE7: doesnt show anything, not rows and cells, nor string AND gives error in page and generally the siteresponds not well
with my code:
mozzila: everything works perfectly
IE7: runtime error at
Posted: Sun Apr 15, 2007 3:18 pm
by tecktalkcm0391
Why don't you try (dunno if it will work) this:
before the line now working put
Code: Select all
var house_html = document.getElementByTag("table");
// then go:
house_html.innerHTML = htmlstring;
Posted: Sun Apr 15, 2007 3:29 pm
by RobertGonzalez
I think its tagname, nut just tag. I think.
Posted: Mon Apr 16, 2007 9:18 am
by sarris
Nope...didnt work with getElementByTag...
Must be cause i have so many tables on tha page. But still createElement returns the element it self. As long as it works with mozzila my code is ok. There must be a slight differation and its not working on IE7
Posted: Wed Apr 18, 2007 12:42 am
by ryan_mate
You can't seem to set the innerHTML of a table element in IE.
A simple solution is: instead of trying to set the innerHTML to a string which contains the code for the table rows, you could just try adding a string with the entire code for the actual table, and add it to a div:
Code: Select all
var house = document.createElement("div");
var htmlstring = '<table><tr><td width = "180">'+'address'+'</td><td width = "110">Type</td><td align = "center" width = "85" rowspan = "2"><b>'+'size'+' sq.m</b></td><td align = "center" width = "85" rowspan = "2"><b>'+'price'+' €</b></td><td align = "center" width = "130" rowspan = "3">Image Here</td></tr><tr><td><strong>'+'area'+'</strong></td><td>'+'beds'+' rooms</td></tr><tr><td>id: '+'id'+'</td><td><a href="javascript: closerLook('+'id'+')"><small>Closer Look onMap</small></a></td></tr></table>';
house.innerHTML = htmlstring;
Notice that the only change you need is to create a div rather than a table, and simply insert the the <table> </table> tags into your string.
Alternatively, use the DOM to create table rows and cells and add them programmatically.
- Ryan
Posted: Wed Apr 18, 2007 9:05 am
by sarris
cool...worked with the div. i have problem with the setAttribute though...checked arroung the internet and many people have problems with IE7...it doesnt fully support many common functionalities...anyways thanks
Posted: Wed Apr 18, 2007 10:29 am
by RobertGonzalez
Yup, you can thank Microsoft for their new standards compliant web browser.
Sorry, I should not have used this as a means to bash Microsoft. But it was hard to resist.
Posted: Thu Apr 19, 2007 6:56 am
by sarris
hahaha...dont worry. its giving me a hard time over and over again. i try to make something work, in the end i do and then i have to test it to stupid IE7 and always something is going wrong.