Re: Special Characters

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Joe Fawcett (joefawcett_at_hotmail.com)
Date: 09/21/04


Date: Tue, 21 Sep 2004 16:16:27 +0100


"Christoph Basedau" <e_tonne@hotmail.com> wrote in message
news:4150159d$0$26101$9b4e6d93@newsread4.arcor-online.net...
> 21.09.2004 12:56, Mark Jerzykowski schrieb:
> > What I am doing is simply passing some text/html to some jscript which
puts
> > inside a div using innerHTML to create a popUp type of thing. Most of
the
> > time it works ok. However, here a few examples that don't work:
> > ----------------------------------
> > <span onMouseOver="popUp( this ,, 0 )" onMouseOut="popUpOff()"
style="cursor:help;">mobile
> > telephone doesn&#039;t work
> >
> > ....</span></td>
> > ------------------------------
> > <span onMouseOver="popUp( this , 'Added new company and I thought I set
the
> > Web Page but it came up as a Email address.<br/>Tried to fix it by
removing
> > the email (which is not easy) and setting web page
again.<br/>Didn&#039;t
> > seem to work so tried again....<br/>I seem to create a new record each
time
> > for the company.<br/>Below results of a Search
Company<br/><br/><br/>Company
> > Location Phone Email <br/>Scottish Provident
> > http://www.scotprov.co.uk/index.htm <br/>Scottish Provident
> > http://www.scotprov.co.uk/index.htm <br/>Scottish Provident
> > http://www.scotprov.co.uk/index.htm <br/>Scottish Provident
> > www.scotprov.co.uk <br/><br/><br/>Doug.' , 0 )" onMouseOut="popUpOff()"
> > style="cursor:help;">Added new company and I thought I set the Web
> > Page...</span>
> > ---------------------------------
>
> One problem is that you break the string. This is not according to
syntax-rules
> of JScript (and also most other Script- and Programming-languages btw). At
EOL
> you have to close the string and then concatenate the next substr.
>
> alert ( "a"
> + "b"
> + "c");
>
> Next problem is that you also /should/ escape the <, </ and > with
entitites:
> &lt; &lt;/ and &gt;. Also IE is forgiving in this context, afaik.
> revised code:
>
> onMouseOver="popUp( this , 'Added new company and I thought I set the'
> + ' Web Page but it came up as a Email address.&lt;br/&gt;Tried to fix
it by removing'
> + ' the email (which is not easy) and setting web page
again.&lt;br/&gt;Didn&#039;t'
> ...');
>
> The most obvious problem is a design/style problem, to my opinion.
> I think it's not a good idea to pack such big literal strings into
> a function arg.
> You could instead make a global-array (dictionary) and map the strings via
the ids of
> the spans. Then you have tiny function calls and the popUp-Function gets
the
> html-code from the dictionary.
> This also more transparent for updating the popup-contents.
>
> <script type="text/Jscript">
>
> var st = new Object(); //st == string_table;
> st['mobile'] = 'mobile telephone
doesn&#039;twork&lt;br/&gt;&lt;br/&gt;';
> st['add_comp'] = 'Added new company and I thought I set the Web Page but
it '
> + 'came up as a Email address.&lt;br/&gt;Tried to fix it by
removing';
>
> //... more strings
>
> function popUp (el, flag) {
> var code = st[el.id]; //'code' replaces your former 2nd arg
> ..
> }
> </script>
>
> <span id="mobile" onMouseOver="popUp(this, 0)" onMouseOut="popUpOff()"
style="cursor:help;">
> <span id="add_comp" onMouseOver="popUp(this, 0)" onMouseOut="popUpOff()"
style="cursor:help;">
> Added new company and I thought I set the Web Page...</span>
>
>
>
> --
> Gruesse, Christoph
>
> Rio Riay Riayo - Gordon Sumner, 1979
I would avoid putting long text strings into inline calls. An alternative
would be to have a number of hidden spans on the page with different IDs.
Then call the function and pass the string via
document.getElementById('myId').innerText.

-- 
Joe (MVP)


Relevant Pages

  • Re: How to fix spaces between last name comma first name
    ... algorithm deals with multiple consecutive spaces, though, removing all but ... Assume neither * neither % initially occur in the string. ... first name without removing spaces between first name and middle ...
    (microsoft.public.access.queries)
  • Re: READ THE FINE PRINT
    ... said "caution string may come uncoiled when removing it from package". ... Troy Donaghue III ...
    (rec.music.classical.guitar)
  • Re: Capitalizing Acronyms
    ... removing the /g and the + doesn't help. ... =:\ That's why I'm using foreach. ... my $string = 'Off The Menu'; ... Shlomi Fish http://www.shlomifish.org/ ...
    (perl.beginners)
  • Re: Database Lookup Functoid Access Connection String
    ... try removing some part of the string I suggested? ... try removing "Persist Security Info=False" or something. ... representing himself and not the company he works for. ...
    (microsoft.public.biztalk.general)
  • Re: [PATCH 1/2] strstrip API
    ... This patch adds a new strstrip() function to lib/string.c for removing ... leading and trailing whitespace from a string. ...
    (Linux-Kernel)