473,320 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

quote problem

Can someone tell me how to get this line to work?

document.write (" <input type='button' value='Make this your home
page' onclick='this.style.behavior="url(#default#homepag e)";
this.setHomePage("http://www.somewhere.com");' />");

Seems no matter what I try, it either throws an error (expected ')'), or
just does nothing. It would seem that escaping is not the answer in this
case (it didn't work).

I only want this button to show if the browser is IE 5+ for obvious
reasons.

The entire script:
<script type="text/javascript">
if (navigator.appName == "Microsoft Internet Explorer" &&
navigator.appVersion >= "5.0") {
document.write ("<form>");
document.write (" <div align='center'>");
document.write (" <input type='button' value='Make this your home
page' onclick='this.style.behavior="url(#default#homepag e)";
this.setHomePage("http://www.somewhere.com");' />");
document.write (" </div>");
document.write ("</form>");
}
</script>

Thanks.

-- Don
Jul 20 '05 #1
4 2012
In article <Xn**********************************@216.168.3.44 >,
dc*******@nospam.email.com enlightened us with...
Can someone tell me how to get this line to work?

Browser detection sucks.
Use conditional IE comments to target IE only.

http://msdn.microsoft.com/library/default.asp?
url=/workshop/author/dhtml/overview/ccomment_ovw.asp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> New Document </title>

</head>

<body>
test
<!--[if gte IE 5]>
<input type='button' value='Make this your home page'
onclick='this.style.behavior="url(#default#homepag e)";
this.setHomePage("http://www.somewhere.com");' />
<![endif]-->
</body>
</html>

--
--
~kaeli~
Experience is something you don't get until just after you
need it.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2
Don:

document.write ("<input type='button' value='Make this your home page'
onclick='this.style.behavior=\"url(#default#homepa ge)\";
this.setHomePage(\"http://www.somewhere.com\");'/>");

You have to escape the quotes.

Orlando, aka, Cycloneous
Don Crossman wrote:
Can someone tell me how to get this line to work?

document.write (" <input type='button' value='Make this your home
page' onclick='this.style.behavior="url(#default#homepag e)";
this.setHomePage("http://www.somewhere.com");' />");

Seems no matter what I try, it either throws an error (expected ')'), or
just does nothing. It would seem that escaping is not the answer in this
case (it didn't work).

I only want this button to show if the browser is IE 5+ for obvious
reasons.

The entire script:
<script type="text/javascript">
if (navigator.appName == "Microsoft Internet Explorer" &&
navigator.appVersion >= "5.0") {
document.write ("<form>");
document.write (" <div align='center'>");
document.write (" <input type='button' value='Make this your home
page' onclick='this.style.behavior="url(#default#homepag e)";
this.setHomePage("http://www.somewhere.com");' />");
document.write (" </div>");
document.write ("</form>");
}
</script>

Thanks.

-- Don

Jul 20 '05 #3
You're right. Actually, the problem is something screwy in the if
statement. The script bails in IE 6.

Cycloneous Echevarria <or*****@engr.uconn.edu> wrote in
news:Ul*******************@newssvr16.news.prodigy. com:
Don:

document.write ("<input type='button' value='Make this your home page'
onclick='this.style.behavior=\"url(#default#homepa ge)\";
this.setHomePage(\"http://www.somewhere.com\");'/>");

You have to escape the quotes.

Orlando, aka, Cycloneous
Don Crossman wrote:
Can someone tell me how to get this line to work?

document.write (" <input type='button' value='Make this your home
page' onclick='this.style.behavior="url(#default#homepag e)";
this.setHomePage("http://www.somewhere.com");' />");

Seems no matter what I try, it either throws an error (expected ')'),
or just does nothing. It would seem that escaping is not the answer
in this case (it didn't work).

I only want this button to show if the browser is IE 5+ for obvious
reasons.

The entire script:
<script type="text/javascript">
if (navigator.appName == "Microsoft Internet Explorer" &&
navigator.appVersion >= "5.0") {
document.write ("<form>");
document.write (" <div align='center'>");
document.write (" <input type='button' value='Make this your
home
page' onclick='this.style.behavior="url(#default#homepag e)";
this.setHomePage("http://www.somewhere.com");' />");
document.write (" </div>");
document.write ("</form>");
}
</script>

Thanks.

-- Don


Jul 20 '05 #4
ExGuardianReader <no***@noway.com> writes:

(What are you answering?)
You can always use &#x22 to put a double quote character inside a
string, and &#x27 to put an apostrophe in.


"Always" is too much. The string "&#x22" is an HTML entity. If your
Javascript is not embedded in a HTML file, e.g., an external Javascript
file, then it will not work.

What will work is "\x22" inside a Javascript string literal. That is the
Javascript escape, not the HTML one.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: davegraham_1998 | last post by:
Hi All- I'm pretty sure this have been discussed earlier, but couldn't find a solution to my problem. <input type="submit" value="Delete Parts" onclick="return handleDeleteParts('ABC', 'MY...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Anonieko | last post by:
Hello ASPNET guru's, What is a clean way to go around the problem of displaying a GridView templated column where data can contain Single Quote ( ' )? I maybe too naive, but this is of course...
5
by: dfetrow410 | last post by:
I know the typical fix for this problem, but I am not sure how to fix this line: <a...
2
by: thecoolone | last post by:
I am stuck at a wierd problem. I am trying to do comparision between a "query string" and a "string value". the string consists of some diacriticals and single quotes. But when i try to escape the...
5
by: xzzy | last post by:
I am writing an app that enables a user to reply to a newsgroup. The proper syntax for From: is "screen name" email@address.com and over all, it should look like: --
8
by: Choi | last post by:
Hi ! I wonder how I can replace a quote by a "\n" in a string. For example my string is rrrrrrr'ttttttt and I want to obtain : rrrrrrr ttttttt I tried the function find, but I don't know...
9
by: D1R | last post by:
I have to migrate a web application written in PHP and I am using PHP 5.2.6 ISAPI. The problem I have is related to some sql queries that have the following format: $sql = "insert into...
9
by: WebArchitect | last post by:
I have a text file. My text file contains lines with double quotes around it. I trying to code if a line has double quotes around it Then make it bold My code is below and it is not working....
6
by: Joseph Stateson | last post by:
I just started calling a php module from html. I added "php rocket" from microsoft to FP2003 but dont think that is the cause. The problem is that I am getting a backslash before a double or...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.