471,305 Members | 1,026 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,305 software developers and data experts.

.innerHTML bug with mozilla/firefox (Ajax)

Hi!

I am currently developping a user interface with Ajax/C#/.net. And I am
facing a problem with Mozilla, and Firefox.

I use the function innerHTML to load a Web UserControl into a div, this
way the main page never gets refreshed. It works perfectly under IE,
but with Mozilla and Firefox I got a problem : there is a space before
the thing I want to display everytime I use ".innerHTML".

For example:

I have a div called "test" like ...
=> "something"
When I use test.innerHTML = "something else", I get ...
=> "
something else"
Could someone help me, please?

Apr 10 '06 #1
8 7615
Clément wrote:
I have a div called "test" like ...
=> "something"
When I use test.innerHTML = "something else", I get ...
=> "
something else"
[...]


Why, `div' elements are block-level elements by default. So they may have
a (top) margin, and the parent block-level element may have a (top) padding.
If you do not want the padding or the margin (as defined in the basic
stylesheet), you have to set it to 0, using CSS.

That there is a padding or a margin is no bug at all.
PointedEars
Apr 10 '06 #2
All the margin and padding values are set to 0px.
And actually, everytime I execute the function, the display change!
so it is like ...

original page
=> "something"
test.innerHTML = "something else"
=> "
something else"
test.innerHTML = "something else"
=> "

something else"
test.innerHTML = "something else"
=> "
something else"
I cheked the code in the innerHTML, with the function alert.
And there is another problem.
In fact, when I do :
test.innerHTML =
'<div><table><tr><td>something</td></tr></table></div>'
The result is weird, because I check the code with an alert and I get
....
alert(test.innerHTML);
=>'<div></div><table><tr><td>something</td></tr></table>'

Why does Mozilla do that?? Apparently, Netscape does the same.

Apr 11 '06 #3
Clément wrote:
All the margin and padding values are set to 0px.
And actually, everytime I execute the function, the display change!
so it is like ...

original page
=> "something"
test.innerHTML = "something else"
=> "
something else"
test.innerHTML = "something else"
=> "

something else"
test.innerHTML = "something else"
=> "
something else"
Weird. But .innerHTML is proprietary, so one should not expect consistent
results.
I cheked the code in the innerHTML, with the function alert.
And there is another problem.
In fact, when I do :
test.innerHTML =
'<div><table><tr><td>something</td></tr></table></div>'
The result is weird, because I check the code with an alert and I get
...
alert(test.innerHTML);
=>'<div></div><table><tr><td>something</td></tr></table>'

Why does Mozilla do that?? Apparently, Netscape does the same.


The are dozens of versions of Mozilla (Seamonkey) and Netscape (Navigator).
None of my innerHTML-capable Mozilla browsers[1] does show such a behavior.
Which ones have you tested with (Help, About)?

The code you posted is insufficient for problem analysis. Please post the
public URL of a test case. (Maybe in creating that test case, you will
find the problem yourself.)

Please quote what you are replying to, as customary on Usenet.[2][3]
PointedEars
___________
[1] Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060205
Debian/1.7.12-1.1

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040805
Netscape/7.2

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4.1) Gecko/20020508
Netscape6/6.2.3

[2] <URL:http://www.safalra.com/special/googlegroupsreply/>

[3] <URL:http://jibbering.com/faq/faq_notes/pots1.html>
news:12****************@PointedEars.de
Apr 11 '06 #4
Thomas 'PointedEars' Lahn wrote:
Clément wrote:
[...]
In fact, when I do :
test.innerHTML =
'<div><table><tr><td>something</td></tr></table></div>'
The result is weird, because I check the code with an alert and I get
...
alert(test.innerHTML);
=>'<div></div><table><tr><td>something</td></tr></table>'

Why does Mozilla do that?? Apparently, Netscape does the same.


[...]
None of my innerHTML-capable Mozilla browsers[1] does show such a
behavior. [...]
___________
[1] Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060205
Debian/1.7.12-1.1

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040805
Netscape/7.2

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4.1) Gecko/20020508
Netscape6/6.2.3


I forgot

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.1) Gecko/20060313
Debian/1.5.dfsg+1.5.0.1-4 Firefox/1.5.0.1
PointedEars
Apr 11 '06 #5
> The are dozens of versions of Mozilla (Seamonkey) and Netscape (Navigator).
None of my innerHTML-capable Mozilla browsers[1] does show such a behavior.
Which ones have you tested with (Help, About)?
This is the version of Mozilla/Firefox I am using ...
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.0.1)
Gecko/20060111 Firefox/1.5.0.1

The code you posted is insufficient for problem analysis. Please post the
public URL of a test case. (Maybe in creating that test case, you will
find the problem yourself.)


I can't create a test case on a public URL because I am developping
this application with C# / .net, and servers for it are not free!
Moreover, I don't have the right to do it vis-a-vis of my company.

But to explain you a little more, I have a main page in which I have 3
div. I load web user controls dynamically (with ajax) in one of them.
The code generated by the WUC, which contains another div that contains
other things (this way <div><table> ... </table></div>), is put in the
div with the function .innerHTML. And as I told you, with IE it works
perfectly, but with Mozilla/Firefox and Netscape the code into the
div.innerHTML is changed like "<div></div><table>...</table>".

Apr 11 '06 #6
I found a solution!
It is really weird...

In fact I was using an asp:panel in my aspx page, that was replaced in
the navigator by a DIV, which is normal, but that DIV had this strange
behavior I explained.
I really don't know why! But by replacing this asp:panel by a standard
DIV, the problems disappear!!!

Thanks anyway for your help!

Apr 11 '06 #7
Thomas 'PointedEars' Lahn wrote:

Weird. But .innerHTML is proprietary, so one should not expect consistent
results.


I've had quite consistent results with innerHTML most of the time. The
only time I've had problems is when I've tried using innerHTML to add
rows to a table (there are better ways to do that) and to add items to a
SELECT (there are better ways to do that, too). Otherwise, it's been
quite consistent.

Are there instances of inconsistencies other than those I mentioned that
you can point me to? And what browsers? That info could prove useful...
Apr 11 '06 #8
spsoni
1
Hi there,

Recently I am also facing similar problem of extra space above DIV, in my html when I am fetching dynamic information using ajax.

I am calling my php code using AJAX, and when assigning returned result as follows:

element.innerHTML = xmlhttp.responseText;

is creating some extra space in my main page.

and the beauty of this problem is that, it is working fine with Firefox and all, but not with IE 6.

I believe, there is some extra special characters coming from my php code, but I cannot trace returned text, since view source do not work for AJAX received data.

Please help.

Same problem with me, I cannot share the code or link, its all paid stuff.

Thanking you advance for your help.

Regards,

Surya


I found a solution!
It is really weird...

In fact I was using an asp:panel in my aspx page, that was replaced in
the navigator by a DIV, which is normal, but that DIV had this strange
behavior I explained.
I really don't know why! But by replacing this asp:panel by a standard
DIV, the problems disappear!!!

Thanks anyway for your help!
May 4 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by ekimnosnews | last post: by
2 posts views Thread by sajithamol | last post: by
3 posts views Thread by carolinevdp | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.