473,395 Members | 1,341 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,395 software developers and data experts.

alternating quotes doesn't seem to be working

dot
I'm trying to use the following hack to create an expanding/contracting
list of links:

<html>
<head>
<script language="Javascript" type="text/javascript">
function ChangeText(obj, originalText, newText){
if(obj.clicks == 1){
obj.innerHTML = originalText;
obj.clicks = 0;
}
else{
obj.innerHTML = newText;
obj.clicks = 1;
}}
</script>
</head>

<body>
<a href="javascript:void(0);" class="news"
onClick="ChangeText(news1,'','state2 ');">Summer 2004<div
id="news1"></div>

<a href="javascript:void(0);" class="news"
onClick="ChangeText(news1,'', '<a href="dir/file.html"> Link </a>

<p>');" Href example <div id=new2"></div>

</body>
</html>
The first call to ChangeText works, showing or hiding the text. The
second call with the quoted string in the href treats the double quote
after file.html as the matching quote that starts the string "ChangeText(...
I thought it was legal to embed the same kind of quote as long as you
alternate quote types (single/double). I guess not. I've tried escaping
the interior double quotes, but that doesn't seem to work either.

What am I missing?
Thanks
Jul 23 '05 #1
4 1470
nothing i guess can't figure it out worse completedifferent behaviour
in mozilla and explorer :((

well you can remove the inner " u dont need it.
i used firefox it worked after removing the inner quotes but not on
explorer
:(

Jul 23 '05 #2
<html>
<head>
<script language="Javascript" type="text/javascript">
function ChangeText(obj, originalText, newText){
if(obj.clicks == 1){
obj.innerHTML = originalText;
obj.clicks = 0;
}
else{
alert(newText);
obj.innerHTML = newText;
obj.clicks = 1;
}}

</script>
</head>

<body>
<a href="javascript:void(0);" class="news"
onClick="ChangeText(news1,'','state2 ');">Summer 2004<div
id="news1"></div>

<a href="javascript:void(0);" class="news"
onClick="ChangeText(news1,'', '<a href=dir/file.html> Link
</a><p>');"> Href example <div id=new2"></div>

</body>
</html>

Jul 23 '05 #3
sancha wrote:
nothing i guess can't figure it out worse completedifferent behaviour
in mozilla and explorer :((

well you can remove the inner " u dont need it.
i used firefox it worked after removing the inner quotes but not on
explorer
:(


Fix the syntax errors and it 'works' in both browsers.

--
Zif
Jul 23 '05 #4
dot wrote:
I'm trying to use the following hack to create an expanding/contracting
list of links:

<html>
<head>
<script language="Javascript" type="text/javascript">
The language attribute has been depreciated for quite some time,
remove it but keep the required type attribute.
function ChangeText(obj, originalText, newText){
if(obj.clicks == 1){
obj.innerHTML = originalText;
obj.clicks = 0;
}
else{
obj.innerHTML = newText;
obj.clicks = 1;
}}
</script>
</head>

<body>
<a href="javascript:void(0);" class="news"
Don't use the javascript pseudo-protocol, just use "#"
onClick="ChangeText(news1,'','state2 ');">Summer 2004<div
id="news1"></div>

<a href="javascript:void(0);" class="news"
onClick="ChangeText(news1,'', '<a href="dir/file.html"> Link </a>
<p>');" Href example <div id=new2"></div>
Once you have nested quotes, just qoute the inner ones and make sure
your HTML is valid (you have forgotten a closing '>'):

<a href="javascript:void(0);" class="news"
onClick="ChangeText(news1,'', '<a href=\'dir/file.html\'> Link </a>
<p>');"> Href example <div id=new2"></div>
------------------^

</body>
</html>
The first call to ChangeText works, showing or hiding the text. The
second call with the quoted string in the href treats the double quote
after file.html as the matching quote that starts the string
"ChangeText(...
I thought it was legal to embed the same kind of quote as long as you
alternate quote types (single/double). I guess not. I've tried escaping
the interior double quotes, but that doesn't seem to work either.

What am I missing?


A cleaner way of doing what you are trying to do. Why not just code
the link, then hide/show it using either 'visibility' or 'display'?
See a simple case below:

<script type="text/javascript">
function toggle(x) {
x = document.getElementById(x);
if (x.style) {
x.style.display = (x.style.display == '')? 'none':'';
}
}
</script>

<span onClick="toggle('X');" style="cursor: pointer;">
Summer 2004
</span>
<div id="news3"></div>
<span id="X"><a href="dir/file.html"> Link </a><br></span>
<span onClick="toggle('X');" style="cursor: pointer;">
Span example
</span>
--
Rob
Jul 23 '05 #5

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

Similar topics

3
by: Kevin | last post by:
I know this has probably been discussed many times before (I found answers when I searched yesterday), but I still can't get it to work... I have an attribute @OID that can contain any...
47
by: Matt Kruse | last post by:
http://www.mattkruse.com/temp/css_expressions.html One of the standard CSS questions is "how can I shade every other table row a different color with CSS?" The answers are usually 1) you can't...
1
by: Eirik Eldorsen | last post by:
I'm trying to set alternating bgcolor for a datalist with 2 columns. My problem is that its the alternating cell that get the bgcolor, not the row. Is it possible to set alternating color of rows?...
4
by: Rob | last post by:
Is there a way to set alternating item style for a ListBox? I know it doesn't exist but is there a way to mimmick the Datagrid's AlternatingItemStyle? Thanks Rob *** Sent via Developersdex...
9
by: Max Weebler | last post by:
Hi, I have a datagrid built that has an alternating item style that sets the backcolor and ForeColor of its rows. I have 4 template columns. One of them has a LinkButton embedded in it to...
1
by: Steve Bottoms | last post by:
Hi, all! How does one prevent table cell background colors from alternating between grey and white? I've dropped a basic table control on an ASP.Net page (using VB.Net codebehind), and...
1
by: Stuart Shay | last post by:
Hello All: I am working on a ASP.NET GridView, I am not sure to correctly define the condition so Alternating Rows are fired with in the event. My Code only works on Item Rows in both Normal and...
37
by: Ian Rastall | last post by:
I've been working on an online books site for almost four years now, and have been putting smart quotes in each book. This is a major hassle, and I'm beginning to think it's not worth it. Is...
10
by: Jon | last post by:
All, Yes, it's more of the famous 'what do I do about magic_quotes' questions. Anyways, here we go: I've been a PHP developer for about a year now, and have grown to detest magic_quotes for...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.