S
SuneR
Hi,
I am having problems figuring out how to make Firefox behave, and
output the HTML I want it to output.
The thing I want done is actually quite simple. I have a <label> tag,
and inside it, I have a script tag, that document.write's some HTML.
Like this:
<label>
<script type="text/javascript">
document.write("<div>Test<\/div>");
</script>
</label>
In Internet Explorer, the result is this:
<label>
<script type="text/javascript">
document.write("<div>Test<\/div>");
</script>
<div>Test</div>
</label>
But in Firefox it is
<label>
<script type="text/javascript">
document.write("<div>Test<\/div>");
</script>
</label>
<div>Test</div>
In other words, the <div> is added AFTER the closing </label> tag.
If I change the script to make a document.write("<span>Test<\/span>");
the output is ok in Firefox.
It seems that if you try to document.write a block level element
inside an inline element, Firefox moves it outside the inline element.
I have a stylesheet that makes the outputtet div inline, but Firefox
moves it no matter what.
I am sure this is behaviour as intented from Firefox, since this
happens in both FF2 and FF3, but what can I do to make it work?
Im thinking some sort of code to automatically append the <div> to the
parent element. My problem here is, that I never really know what type
of parent element it is. And I cant just append it at the end because
my output might be in the middle of the parents innerHTML.
Any ideas? Tips? Thoughts?
I am having problems figuring out how to make Firefox behave, and
output the HTML I want it to output.
The thing I want done is actually quite simple. I have a <label> tag,
and inside it, I have a script tag, that document.write's some HTML.
Like this:
<label>
<script type="text/javascript">
document.write("<div>Test<\/div>");
</script>
</label>
In Internet Explorer, the result is this:
<label>
<script type="text/javascript">
document.write("<div>Test<\/div>");
</script>
<div>Test</div>
</label>
But in Firefox it is
<label>
<script type="text/javascript">
document.write("<div>Test<\/div>");
</script>
</label>
<div>Test</div>
In other words, the <div> is added AFTER the closing </label> tag.
If I change the script to make a document.write("<span>Test<\/span>");
the output is ok in Firefox.
It seems that if you try to document.write a block level element
inside an inline element, Firefox moves it outside the inline element.
I have a stylesheet that makes the outputtet div inline, but Firefox
moves it no matter what.
I am sure this is behaviour as intented from Firefox, since this
happens in both FF2 and FF3, but what can I do to make it work?
Im thinking some sort of code to automatically append the <div> to the
parent element. My problem here is, that I never really know what type
of parent element it is. And I cant just append it at the end because
my output might be in the middle of the parents innerHTML.
Any ideas? Tips? Thoughts?