Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #10421
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | "Jukka K. Korpela" <jkorpela@cs.tut.fi> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Shrinking the width of a WIDTH=100% table |
| Date | Fri, 20 Jan 2012 17:04:27 +0200 |
| Organization | A noiseless patient Spider |
| Lines | 46 |
| Message-ID | <jfbvpn$u7v$1@dont-email.me> (permalink) |
| References | <8nsih7pjdunj21096qub8tnr1mluk2bons@4ax.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Fri, 20 Jan 2012 15:04:24 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="ngroV0xYIIv0dzjhyZhv5A"; logging-data="30975"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+SZzk5Iq81QBvmrmXigK1" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 |
| In-Reply-To | <8nsih7pjdunj21096qub8tnr1mluk2bons@4ax.com> |
| X-Antivirus-Status | Clean |
| X-Antivirus | avast! (VPS 120120-0, 20.01.2012), Outbound message |
| Cancel-Lock | sha1:Nqw+nSM3Cpyl/NCRmR2iQuGker4= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.javascript:10421 |
Show key headers only | View raw
2012-01-20 16:04, Swifty wrote:
> Is there any JavaScript that I can insert, after the <TABLE> has
> already been started, which will remove the effect of the WIDTH=100%
Yes. I suppose you have considered the obvious solution of not writing
WIDTH=100% for a specific table, and I suppose the reason for rejecting
that idea is in the logic of your server-side code: you're in the midst
of writing data when you find out that something should have been done
earlier.
Using JavaScript, you could change the width property of the <table>
element. For this, you could e.g. emit an empty <span> element with an
id so that appears inside a cell of the table, then traverse the
document tree upwards until you find the <table> element:
<table width="100%" border>
<tr><td>Hello world <td>Hello again
<tr><td>Foo <td> Bar
<span id="foo"></span>
<script>
var el = document.getElementById('foo');
do {
el = el.parentNode;
} while (el.tagName != 'TABLE');
el.width = '';
</script>
</table>
(So the <span> and <script> elements are what you would need to add to
the generated markup. The identifier 'foo' can be anything as long as it
is unique within the document.)
> I'm open to a CSS solution as well, but there are other tables in the
> same page which must remain WIDTH=100% so it would have to be specific
> to just this one table.
You cannot validly emit CSS code that would affect the table that has
been started. No style attribute can do that. A <style> element would,
but it's invalid in <body> (though browsers allow it, to the extent that
it might even be declared a feature). And to make a CSS rule apply to a
specific table, you would probably need a class attribute on it, but I
suppose it would be too late to emit one.
--
Yucca, http://www.cs.tut.fi/~jkorpela/
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Shrinking the width of a WIDTH=100% table Swifty <steve.j.swift@gmail.com> - 2012-01-20 14:04 +0000
Re: Shrinking the width of a WIDTH=100% table Captain Paralytic <paul_lautman@yahoo.com> - 2012-01-20 06:20 -0800
Re: Shrinking the width of a WIDTH=100% table "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-01-20 17:04 +0200
Re: Shrinking the width of a WIDTH=100% table Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-01-20 16:35 +0100
Re: Shrinking the width of a WIDTH=100% table "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-01-20 19:45 +0200
Re: Shrinking the width of a WIDTH=100% table Swifty <steve.j.swift@gmail.com> - 2012-01-20 18:49 +0000
Re: Shrinking the width of a WIDTH=100% table "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-22 13:57 -0800
Re: Shrinking the width of a WIDTH=100% table Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-20 22:17 +0100
Re: Shrinking the width of a WIDTH=100% table Swifty <steve.j.swift@gmail.com> - 2012-01-21 06:28 +0000
Re: Shrinking the width of a WIDTH=100% table "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-01-21 11:07 +0000
Re: Shrinking the width of a WIDTH=100% table Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-21 19:52 +0100
Re: Shrinking the width of a WIDTH=100% table Swifty <steve.j.swift@gmail.com> - 2012-01-22 06:54 +0000
Re: Shrinking the width of a WIDTH=100% table Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-22 14:06 +0100
Re: Shrinking the width of a WIDTH=100% table "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-01-22 15:17 +0200
Re: Shrinking the width of a WIDTH=100% table Swifty <steve.j.swift@gmail.com> - 2012-01-23 06:52 +0000
Re: Shrinking the width of a WIDTH=100% table Swifty <steve.j.swift@gmail.com> - 2012-01-23 07:10 +0000
Re: Shrinking the width of a WIDTH=100% table Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-23 16:36 +0100
Re: Shrinking the width of a WIDTH=100% table Dr J R Stockton <reply1203@merlyn.demon.co.uk> - 2012-01-21 20:50 +0000
Re: Shrinking the width of a WIDTH=100% table Swifty <steve.j.swift@gmail.com> - 2012-01-22 06:42 +0000
csiph-web