By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,460 Members | 1,181 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,460 IT Pros & Developers. It's quick & easy.

'wrap' inconsistency? createElement VS document.write

P: n/a
Hello,

im some image elements using doc.createElement('IMG');
i set the following styles:
- for the images container: white-space:normal;
- for the images themselves: display: inline;

i append the images to the body ... but the imagery dont wrap when the
window gets smaller, unless i append a space (createTextNode) after each
image

HOWEVER, when i write it with HTML: <img src="" ...><img src="" ...><img
src="" ...> it wraps fine
Is this normal??

Pieter

Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a


Pieter Van Waeyenberge wrote:

im some image elements using doc.createElement('IMG');
i set the following styles:
- for the images container: white-space:normal;
- for the images themselves: display: inline;

i append the images to the body ... but the imagery dont wrap when the
window gets smaller, unless i append a space (createTextNode) after each
image

HOWEVER, when i write it with HTML: <img src="" ...><img src="" ...><img
src="" ...> it wraps fine
Is this normal??


Write a small test case demonstrating the problem, post a URL and tell
us which browser(s) exhibit the problem. Then someone can better give an
opinion on why that occurs or shouldn't occur.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

P: n/a
sorry, some more detail:
(i dont have URL handy and the whole script is too complex to post it here)

i only tested on most recent NS & IE, and the code behaves the same ...

SCENARIO 1: images do NOT wrap
--------------------------------------
<script>
onload = function(){
var foo = document.createElement('IMG');
foo.src = 'foo.jpg';

var goo = document.createElement('IMG');
goo.src = 'goo.jpg';

var myBody = document.getElementsByName('BODY');
myBody = myBody.item(0);

myBody.appendChild(foo);
myBody.appendChild(goo);
}
</script>
<body>
</body>

SCENARIO 2: images wrap
--------------------------------------
<body>
<img src="foo"><img src="goo">
</body>

Remark: i also tried putting the images of SCENARIO 1 in a container with
'white-space:normal;' and the images themselves 'display:inline;' ... still
no wrapping when flow should go to next line, instead i get scrollbar and
all on one line ... unlike in SCENARIO 2

However, in SCENARIO 1, i obtain wrapping when i explicitly add some
white-space after every image ... sounds logical, but in SCENARIO 2 theres
no whtespace between the images so i find it inconsistent?

I hope this is more clear ....
Pieter.

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:40********@olaf.komtel.net...


Pieter Van Waeyenberge wrote:

im some image elements using doc.createElement('IMG');
i set the following styles:
- for the images container: white-space:normal;
- for the images themselves: display: inline;

i append the images to the body ... but the imagery dont wrap when the
window gets smaller, unless i append a space (createTextNode) after each
image

HOWEVER, when i write it with HTML: <img src="" ...><img src="" ...><img
src="" ...> it wraps fine
Is this normal??


Write a small test case demonstrating the problem, post a URL and tell
us which browser(s) exhibit the problem. Then someone can better give an
opinion on why that occurs or shouldn't occur.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3

P: n/a
ignore this thread .. i didnt set whitespace = normal explicitly in the
containing elemnt

pieter.

"Pieter Van Waeyenberge" <p@foo.com> wrote in message
news:40*********************@news.skynet.be...
Hello,

im some image elements using doc.createElement('IMG');
i set the following styles:
- for the images container: white-space:normal;
- for the images themselves: display: inline;

i append the images to the body ... but the imagery dont wrap when the
window gets smaller, unless i append a space (createTextNode) after each
image

HOWEVER, when i write it with HTML: <img src="" ...><img src="" ...><img
src="" ...> it wraps fine
Is this normal??

Pieter

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.