[BNM] JavaScript and HTML Escaping

Julian Blundell old at w34u.com
Mon Jan 15 12:54:30 GMT 2007


Why don't you write a procedure and just call it on the event?

Jules

On 15/01/07, Dave Child <dave at ilovejackdaniels.com> wrote:
>
> Hi Ben,
>
> That will work, but I really don't want to use single quotes in HTML - if
> I remember correctly, single quotes are invalid HTML and not handled well
> by all browsers. If I use double quotes to wrap the attribute in, I then
> need to use single quotes inside it.
>
> All that said, that's closer than I've managed to get to make this work so
> far!
>
> Thanks
> Dave
>
> On Mon, 15 Jan 2007 12:28:53 -0000, Ben Scott <ben at ben-scott.co.uk> wrote:
>
> >
> > Hi Dave -
> >
> > I think you can use the escape character \ - but you need to use the
> > same quotes for the attribute and the function parameter.
> >
> >  So both of these should work:-
> >
> > <a href="#" onClick='addSubContent("<tr><td
> > colspan=\"2\">stuff</td></tr>");return false;'>link</a>
> > <a href="#" onClick="addSubContent('<tr><td
> > colspan=\'2\'>stuff</td></tr>');return false;">link</a>
> >
> > Cheers, ben
> >
> >
> >
> > Dave Child wrote:
> >> Hi :)
> >>
> >> I'm having trouble with characters in javascript.
> >>
> >> Here's the line that's giving me issues:
> >>
> >> <a href="#" onClick="addSubContent('<tr><td
> >> colspan="2">stuff</td></tr>');
> >> return false;">link</a>
> >>
> >> I want to send HTML as a parameter to a javascript function call.
> >> However,
> >> the quote marks in the HTML break the HTML itself. It seems there's no
> >> such thing as an escape character in HTML. Any idea how I can send HTML
> >> with attributes as a parameter to a javascript function from an inline
> >> call?
> >>
> >> Thanks
> >> Dave
> >>
> >>
> >
>
>
>
> --
> www.ilovejackdaniels.com - Web Marketing and Development
> --
>
> BNM info/subscription/archives: http://www.brightonnewmedia.org/
> BNM archive search: http://www.roddis.org/bnm/search.php
> BNM Del.icio.us tag: http://del.icio.us/tag/bnm/
> BNM Flickr group: http://www.flickr.com/groups/bnm/
> BNM powered by Wessex Networks http://www.wessexnetworks.com
>



More information about the BNMlist mailing list. Powered by Wessex Networks