Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28543
| Path | csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Apply a CSS block onresize? |
| Date | Wed, 19 Aug 2015 18:52:05 +0200 |
| Organization | PointedEars Software (PES) |
| Lines | 65 |
| Message-ID | <2216167.0GtFLWOztQ@PointedEars.de> (permalink) |
| References | <mr255d$eff$1@news.albasani.net> <mr27tg$eqr$1@adenine.netfront.net> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Trace | solani.org 1440003333 3294 eJwFwQEBwDAIAzBNGxSKHF6OfwlLYHFC6YFwLDapilFRpAE45wf7S83KqUsKPujqa5mtBxi2ESM= (19 Aug 2015 16:55:33 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Wed, 19 Aug 2015 16:55:33 +0000 (UTC) |
| User-Agent | KNode/4.14.2 |
| X-User-ID | eJwFwYEBwDAEBMCVeJ5knKD2H6F3tNDo9GA4l9stMlNCuqccUauFG4g39FRm6D0LxEjPHswXewVWWm8ufjAKFLs= |
| Cancel-Lock | sha1:MHHNIUnw0LFIU51N8y/7BCYs15g= |
| X-NNTP-Posting-Host | eJwNwokRwDAIA7CVzPEYxikk7D9CepJrSAwtPMzXl7jLTLIQlYHfwTG2SH+2GOsaL4OuXi8+/+UQKQ== |
| Xref | csiph.com comp.lang.javascript:28543 |
Show key headers only | View raw
Martin Honnen wrote:
> I would not change the id of the element but its class e.g.
I would not do either in this case.
> […]
>> <body onresize="change_display()">
>>
>> <script>
>> if(d.body.scrollWidth < 800){
You should solve this problem with CSS media queries, not scripting.
> d.write('<div id="menu" class="small">');
Do not do that in any case.
1. You are generating an incomplete element. This is error-prone at best.
2. You are generating an element in a render-blocking fashion.
(2) is acceptable if, and only if, you want to ensure maximum backwards-
compatibility. That is, below IE/MSHTML 4 and Netscape 6. (For example,
I am using document.write() as a fallback in the ECMAScript Support Matrix
[see sig] if .appendChild() & friends are unavailable.)
>> }
>> else{
>
> d.write('<div id="menu" class="big">');
See above.
>> }
>> </script>
>>
>> <h2>My big or small menu</h2>
>> <li><a href="#">Item 1</li>
>> <li><a href="#">Item 2</li>
>> etc.
<http://validator.w3.org/> (HTML < 5, XHTML)
<http://validator.w3.org/nu/> (HTML5)
>> <script>
>> d.write('</div>');
No.
> These days CSS might have more powerful rules that don't depend on
> Javascript to adjust your display to the size of the viewport.
It not only might have them, it does: Media Queries.
<https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries> pp.
> --- news://freenews.netfront.net/ - complaints: news@netfront.net ---
You should avoid this source of trolls.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Apply a CSS block onresize? Tuxedo <tuxedo@mailinator.com> - 2015-08-19 16:51 +0200
Re: Apply a CSS block onresize? Martin Honnen <mahotrash@yahoo.de> - 2015-08-19 17:38 +0200
Re: Apply a CSS block onresize? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-08-19 18:52 +0200
Re: Apply a CSS block onresize? Tuxedo <tuxedo@mailinator.com> - 2015-08-19 22:17 +0200
csiph-web