Re: Special Characters
From: Joe Fawcett (joefawcett_at_hotmail.com)
Date: 09/21/04
- Next message: Steven Scaife: "concatenation to reference a page button"
- Previous message: eric_in_stlouis: "Finding name of link a user is about to click"
- In reply to: Christoph Basedau: "Re: Special Characters"
- Next in thread: Christoph Basedau: "Re: Special Characters"
- Reply: Christoph Basedau: "Re: Special Characters"
- Messages sorted by: [ date ] [ thread ]
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'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'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:
> < </ and >. 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.<br/>Tried to fix
it by removing'
> + ' the email (which is not easy) and setting web page
again.<br/>Didn'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'twork<br/><br/>';
> st['add_comp'] = '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';
>
> //... 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)
- Next message: Steven Scaife: "concatenation to reference a page button"
- Previous message: eric_in_stlouis: "Finding name of link a user is about to click"
- In reply to: Christoph Basedau: "Re: Special Characters"
- Next in thread: Christoph Basedau: "Re: Special Characters"
- Reply: Christoph Basedau: "Re: Special Characters"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|