Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #12307

Re: Transposing single and double quotes.

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.straub-nv.de!noris.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="ISO-8859-1"
Message-ID <1404347.V9SEqChMir@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Organization PointedEars Software (PES)
Date Wed, 29 Feb 2012 19:59:51 +0100
User-Agent KNode/4.4.11
Content-Transfer-Encoding 7Bit
Subject Re: Transposing single and double quotes.
Newsgroups comp.lang.javascript
References <u8fsk7h2shahn6niukmv2mb89ekmllhtbe@4ax.com> <h3rsk7peqfvchuii4vnit5vd30ecjmnbo7@4ax.com> <4f4e724b$1@news.broadpark.no>
Followup-To comp.lang.javascript
MIME-Version 1.0
Lines 45
NNTP-Posting-Date 29 Feb 2012 19:59:52 CET
NNTP-Posting-Host 87e3b2db.newsspool3.arcor-online.net
X-Trace DXC=SYEhTD_ond4kUFX=Y?aLP;McF=Q^Z^V384Fo<]lROoR18kF<OcfhCO;a`:6Ko^Zg`<DZm8W4\YJN<UFDj8T]K0?3DmniOZG;K0;bDFlKG8h7>6
X-Complaints-To usenet-abuse@arcor.de
Xref x330-a1.tempe.blueboxinc.net comp.lang.javascript:12307

Followups directed to: comp.lang.javascript

Show key headers only | View raw


KR wrote:

> On 29.02.2012 19:27, Swifty wrote:
>> This leaves me with a different question: How, in HTML, would I enter
>> the JavaScript necessary to get an alert popup:
>> 
>> Please don't click the "Click" button again.
> 
> onClick="alert('Please don\'t click the \u0022Click\u0022 button again')"

More compatible and more efficient, also easier to type and read:

  onclick="window.alert('Please don\'t click the &quot;Click&quot; button 
again')"

or

  onclick="window.alert('Please don\'t click the &#x22;Click&#x22; button 
again')"

or 

  onclick="window.alert('Please don\'t click the &#34;Click&#34; button 
again')"

(no line-break in-between, respectively)

This works because CDATA attribute values like that of event-handler 
attributes are parsed, e. g. for character entity references and character 
references.  That approach has the additional advantage of leaving the 
script engine less to do as it will only "see" the double-quote character as 
passed on from the user agent.

Of course, spaghetti code in attribute values should be avoided in the first 
place.

We have discussed this here before.


PointedEars
-- 
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
  -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Transposing single and double quotes. Swifty <steve.j.swift@gmail.com> - 2012-02-29 15:04 +0000
  Re: Transposing single and double quotes. "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-02-29 17:27 +0200
    Re: Transposing single and double quotes. Swifty <steve.j.swift@gmail.com> - 2012-02-29 18:17 +0000
  Re: Transposing single and double quotes. Scott Sauyet <scott.sauyet@gmail.com> - 2012-02-29 07:28 -0800
  Re: Transposing single and double quotes. Jake Jarvis <pig_in_shoes@yahoo.com> - 2012-02-29 16:39 +0100
  Re: Transposing single and double quotes. Swifty <steve.j.swift@gmail.com> - 2012-02-29 18:27 +0000
    Re: Transposing single and double quotes. Swifty <steve.j.swift@gmail.com> - 2012-02-29 18:38 +0000
    Re: Transposing single and double quotes. KR <kristian.rasmussen@broadpark.no.spam.com> - 2012-02-29 19:45 +0100
      Re: Transposing single and double quotes. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-29 19:59 +0100
        Re: Transposing single and double quotes. "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-29 22:28 +0000
          Re: Transposing single and double quotes. "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-03-01 07:52 +0200
            Re: Transposing single and double quotes. "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-01 07:54 +0000
              Re: Transposing single and double quotes. "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-03-01 10:18 +0200
                Re: Transposing single and double quotes. "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-01 15:21 +0000
                Re: Transposing single and double quotes. "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-03-01 18:07 +0200
              Re: Transposing single and double quotes. Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-03-01 10:30 +0100
                Re: Transposing single and double quotes. "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-01 15:29 +0000
                Re: Transposing single and double quotes. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-03-01 22:10 +0100
                Re: Transposing single and double quotes. Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-03-02 11:02 +0100
                Re: Transposing single and double quotes. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-03-02 13:17 +0100
                Re: Transposing single and double quotes. Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-03-05 10:09 +0100
                Re: Transposing single and double quotes. John G Harris <john@nospam.demon.co.uk> - 2012-03-02 16:27 +0000
              Re: Transposing single and double quotes. Dr J R Stockton <reply1209@merlyn.demon.co.uk> - 2012-03-02 22:05 +0000
                Re: Transposing single and double quotes. "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-03 08:35 +0000
    Re: Transposing single and double quotes. "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-02-29 20:47 +0200
      Re: Transposing single and double quotes. Swifty <steve.j.swift@gmail.com> - 2012-03-01 07:19 +0000
    Re: Transposing single and double quotes. Gene Wirchenko <genew@ocis.net> - 2012-02-29 14:18 -0800
  Re: Transposing single and double quotes. Dr J R Stockton <reply1209@merlyn.demon.co.uk> - 2012-03-01 21:55 +0000

csiph-web