Click to See Complete Forum and Search --> : escape problem


sachin
05-30-2003, 05:02 PM
Hi,

I have small problem out here and i guess it is quiet simple.

<a id="e2" href="/test/09111/520/123.pdf" target="fmContent" class="udrlinesmall" name="Table of Contents" onclick="javascript:jsTitle('Test Manual - What's New in This Guide');">

jsTitle function needs to sets the page title
<script>

function jsTitle(sTitle)
{
window.parent.document.title = sTitle;
}
</script>

Here the poblem is that i/p parameter to jsTitle has a single quote,so how do we espace that so that ' appears in the title
as well as it should not give javascript error.

One more thing is that i have many hyperlinks in the page
which can again have the single quote in the title.

khalidali63
05-30-2003, 05:08 PM
Originally posted by sachin
Hi,
('Test Manual - What's New in This Guide');

replace the above with this

('\'Test Manual - What\'s New in This Guide\'')

EDIT:

cripes forum editor screwed it up...lol

sachin
05-30-2003, 05:27 PM
thanks dave it works.

Charles
05-30-2003, 06:48 PM
Originally posted by Dave Clark
This will work:

onclick="javascript:jsTitle('Test Manual - What\\'s New in This Guide');"

Dave That might work, but only because the browser you are using is ignoring the error. But MSIE hasn't taken over yet. That should be:

onclick="jsTitle('Test Manual - What\\'s New in This Guide');"

sachin
05-30-2003, 07:20 PM
charles,

i did not get you.
can pl let me know in detail.
also why there is a space b/w java & script.
this is surely not work.

onclick="java script:jsTitle('Test Manual - What\'s New in This Guide');"

Charles
05-30-2003, 09:13 PM
You will find, if you read through the backlog of postings, that Dave is only really interested in pages working in MSIE. And as far as JavaScript is concerned, there is something to be said for that but there are hundreds of different browsers out there.

We've had this argument before and yes, my only argument is that it is wrong. Yes it works on most browsers that I know about and it certainly works on most browsers out there, but it's still wrong.