Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

noWrap property for TD tag

 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, I have a requirement to add my TD dynamically and I am able to set all the required properties to TD dynamically using javascript except one.
How to add property which says not to wrap td data inside table..
i.e something statically we do using <TD nowrap>
I tried using javascript as
element.style.noWrap = true
and
element.noWrap = true

assume element in valid TD object here.

Appreciate if any one could reply..
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try

elem.style.whiteSpace = "nowrap";

Eric
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Eric.
But that didnot work. I use IE6.
 
Ajith Vijayan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please try with document.formname.getElementById("elementName").style.wordWrap="normal"
the syntax elementId.style.wordWrap="break-word" is used for introducing word wrap. I think this is the reverse case
 
Joel Jorgensen
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may not be quite what you're looking for, but if you hide the overflow it won't wrap. The potential problem with this is that you will probably also need to explicitly set the width and height of the element (otherwise it will collapse completely) e.g.


There may also be a way to set just the horizontal overflow (elem.style.overflowX, maybe) in which case you would only need to specify the width, e.g.

[ January 04, 2007: Message edited by: Joel Jorgensen ]
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Ajith, Thanks for reply. Welcome to Javaranch. Unfortunately your post didn't work.
Hey Joel, your solution also didnt work for me.. Is that something you tried and working?
 
Liu Zhixiang
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
elem.style.whiteSpace="nowrap"; //It's right!!

But this attribute didn't work as you set the elem's width.
[ January 05, 2007: Message edited by: Liu Zhixiang ]
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Liu.
Hey Eric, your solution worked. I was mentioning it on the TR object instead of TD object. After applying on TD object, it worked.
Thanks for your help as always..
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FYI: I hate CSS!

Eric
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FYI: I hate CSS!

What is the alternative?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiring omeone else to code it!

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic