473,770 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.s tyle.behavior=" url(#default#ho mepage)";
this.setHomePag e("http://www.somewhere.c om");' />");

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.appN ame == "Microsoft Internet Explorer" &&
navigator.appVe rsion >= "5.0") {
document.write ("<form>");
document.write (" <div align='center'> ");
document.write (" <input type='button' value='Make this your home
page' onclick='this.s tyle.behavior=" url(#default#ho mepage)";
this.setHomePag e("http://www.somewhere.c om");' />");
document.write (" </div>");
document.write ("</form>");
}
</script>

Thanks.

-- Don
Jul 20 '05 #1
4 2044
In article <Xn************ *************** *******@216.168 .3.44>,
dc*******@nospa m.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.as p

<!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.s tyle.behavior=" url(#default#ho mepage)";
this.setHomePag e("http://www.somewhere.c om");' />
<![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.s tyle.behavior=\ "url(#default#h omepage)\";
this.setHomePag e(\"http://www.somewhere.c om\");'/>");

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.s tyle.behavior=" url(#default#ho mepage)";
this.setHomePag e("http://www.somewhere.c om");' />");

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.appN ame == "Microsoft Internet Explorer" &&
navigator.appVe rsion >= "5.0") {
document.write ("<form>");
document.write (" <div align='center'> ");
document.write (" <input type='button' value='Make this your home
page' onclick='this.s tyle.behavior=" url(#default#ho mepage)";
this.setHomePag e("http://www.somewhere.c om");' />");
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.u conn.edu> wrote in
news:Ul******** ***********@new ssvr16.news.pro digy.com:
Don:

document.write ("<input type='button' value='Make this your home page'
onclick='this.s tyle.behavior=\ "url(#default#h omepage)\";
this.setHomePag e(\"http://www.somewhere.c om\");'/>");

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.s tyle.behavior=" url(#default#ho mepage)";
this.setHomePag e("http://www.somewhere.c om");' />");

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.appN ame == "Microsoft Internet Explorer" &&
navigator.appVe rsion >= "5.0") {
document.write ("<form>");
document.write (" <div align='center'> ");
document.write (" <input type='button' value='Make this your
home
page' onclick='this.s tyle.behavior=" url(#default#ho mepage)";
this.setHomePag e("http://www.somewhere.c om");' />");
document.write (" </div>");
document.write ("</form>");
}
</script>

Thanks.

-- Don


Jul 20 '05 #4
ExGuardianReade r <no***@noway.co m> 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/rasterTriangleD OM.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
4512
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 DESCRIPTION')">
16
4929
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 Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be easily verified: Implement the following in a web service method (just raises a SOAPException with a...
2
2144
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 a common scenario. Scenario: * My database returns names that can contain single quote.
5
1859
by: dfetrow410 | last post by:
I know the typical fix for this problem, but I am not sure how to fix this line: <a href="javascript:poptastic('../WebPages/AdminViewAdminMessages.aspx?MessageId=<%#DataBinder.Eval(Container.DataItem,"MESSAGE_ID")%>')"><%#DataBinder.Eval(Container.DataItem,"SUBJECT")%></a>
2
1731
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 single quotes using backshash (\) it doesnt work. and when i try to use it inside a double quote preg_replace() doesnt recognise the code. why is php not comaparing string with single quotes??
5
2339
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
1942
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 how to specify in its
9
1251
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 table_name values ('','" . $value1 . "','" . $value2 . "',')"; This fails because PHP will translate this in something like:
9
4562
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. Please Help <? $filename = "whatsnew.txt"; # file to read if (file_exists($filename)) {
6
3189
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 single quote and I cannot figure out how to get ride of it. $query = 'SELECT * FROM cpuinfo where Description like "%xcell%" or Description like "%q6600%" '; The above works perfectly but if I attempt to pass the sql string into the
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.