The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Quotes error, Mission imposible or not ?
shower
post Sep 17 2006, 01:43 PM
Post #1





Group: Members
Posts: 1
Joined: 17-September 06
Member No.: 153



I have a big problem , i need to add the quad quotation marks in themselfs.
My englis is poor, so i will write code down

$html .= '<a href="#" onclick=\'createNewTab("ajax","#{title}","<img src= !THERE! http://pgs.avx.pl/PGBA/loading.gif !THERE! > Proszę czekać, ładowanie...","#{link}");return false\'>#{title}</a><br>';

in place of !THERE! i need to add the fourth quotation mark
So it looks like that:
'.....\'....".....??-and how i can add one more type of quotation mark here?...??...."...\'....'

This post has been edited by shower: Sep 17 2006, 01:45 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Sep 17 2006, 02:06 PM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Hi,

I don't know what programming alnguage you use, but obviously you can use escapes because you did so here: onclick=\'createNewTab . So can't you simply escape all quotes around HTML attributes? Is there a reason you can't do that?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 17 2006, 02:49 PM
Post #3


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



The $html variable looks like PHP, but I don't think that's the problem. The problem seems to be that the onclick event sends an argument containing quotes:

HTML
onclick=\'createNewTab("ajax","#{title}","<img src="http://pgs.avx.pl/PGBA/loading.gif"> Proszę czekać, ładowanie...","#{link}");return false"


Escaping double quotes doesn't seem to help, can't you do that? But if you turn them into single quotes you can escape them:

HTML
onclick="createNewTab('ajax', '#{title}', '<img src=\'http:\/\/pgs.avx.pl\/PGBA\/loading.gif\'> Prosze czekac, ladowanie...', '#{link}'); return false"


Note that this requires rewriting and possible escaping of the PHP variable as well.





User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 17 2006, 02:52 PM
Post #4


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



Also you shouldn't use

CODE
<a href="#" onclick="..."


try instead to use a HREF value that makes sense if javascript is disabled.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Sep 17 2006, 03:06 PM
Post #5


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



You ,mrean the output doesn't work, JS error? I don't understand, do you really mean PHP can't escape double quotes? ohmy.gif

Wouldn't this work?
onclick=\'createNewTab("ajax","#{title}","<img src= \\"http://pgs.avx.pl/PGBA/loading.gif\\">...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 17 2006, 04:03 PM
Post #6


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Sep 17 2006, 10:06 PM) *

You ,mrean the output doesn't work, JS error?


No, isn't it an HTML error if part of the onclick attribute's value is rendered in the link text?

QUOTE
I don't understand, do you really mean PHP can't escape double quotes? ohmy.gif


It can, I just meant PHP is not involved in the basic problem, so I removed it from my examples (maybe that's not very helpful but I feel lazy. blush.gif ).

QUOTE
Wouldn't this work?
onclick=\'createNewTab("ajax","#{title}","<img src= \\"http://pgs.avx.pl/PGBA/loading.gif\\">...


Aha, you must escape double quotes with double backslashes? unsure.gif That seems to work:

CODE
<a href="#" onclick='createNewTab("ajax","#{title}","<img src=\\"http://pgs.avx.pl/PGBA/loading.gif\\"> Prosze czekac, ladowanie...","#{link}");return false'>#{title}</a>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Sep 17 2006, 04:35 PM
Post #7


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



It does? It didn't work for me. laugh.gif

My, probably dumb, thinking was that to print a literal "\" you need to escape it. So it works for you? Maybe I made a typo when I tried. I get nervous around PHP. ninja.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 17 2006, 05:21 PM
Post #8


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



But I'm not inclusing the PHP syntax, I told you! rolleyes.gif

Here's a PHP example since you insist:

CODE

$html .= '<a href="#" onclick=\'createNewTab("ajax","#{title}","<img src=\\"http://pgs.avx.pl/PGBA/loading.gif\\"> Prosze czekac, ladowanie...","#{link}");return false\'>#{title}</a><br>';




User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 17 2006, 05:26 PM
Post #9


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Sep 17 2006, 11:35 PM) *

My, probably dumb, thinking was that to print a literal "\" you need to escape it.


Now I think I understood what you meant (I'm a bit dense for once). That makes sense, but in my post above I didn't mean PHP at all, just plain HTML. It seems you need two backslashes to escape a double quote there too.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 17 2006, 05:30 PM
Post #10


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



Wonder if the OP is enough confused by now? Maybe we (I) should clean up this thread.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Sep 17 2006, 05:42 PM
Post #11


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Double escapes in the JS? ohmy.gif

How can you clean it up when we don't know what's true or not? You'll just delete the wrong, or rather right, things.. rolleyes.gif

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 17 2006, 06:10 PM
Post #12


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Sep 18 2006, 12:42 AM) *

Double escapes in the JS? ohmy.gif


Darn. It seemed to work before.

In other words, you can't escape double quotes in HTML/JS like you can with single quotes?

QUOTE
How can you clean it up when we don't know what's true or not? You'll just delete the wrong, or rather right, things.. rolleyes.gif


Yes ma'm. blush.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 18th April 2024 - 02:07 PM