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> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn 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: <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<]lROoR18kF6 X-Complaints-To: usenet-abuse@arcor.de Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:12307 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 "Click" button again')" or onclick="window.alert('Please don\'t click the "Click" button again')" or onclick="window.alert('Please don\'t click the "Click" 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 (404-comp.)