Quotes error, Mission imposible or not ? |
Quotes error, Mission imposible or not ? |
shower |
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 |
pandy |
Sep 17 2006, 02:06 PM
Post
#2
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,731 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? |
Christian J |
Sep 17 2006, 02:49 PM
Post
#3
|
. Group: WDG Moderators Posts: 9,656 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. |
Christian J |
Sep 17 2006, 02:52 PM
Post
#4
|
. Group: WDG Moderators Posts: 9,656 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. |
pandy |
Sep 17 2006, 03:06 PM
Post
#5
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,731 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?
Wouldn't this work? onclick=\'createNewTab("ajax","#{title}","<img src= \\"http://pgs.avx.pl/PGBA/loading.gif\\">... |
Christian J |
Sep 17 2006, 04:03 PM
Post
#6
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
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? 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. ). 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? 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> |
pandy |
Sep 17 2006, 04:35 PM
Post
#7
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,731 Joined: 9-August 06 Member No.: 6 |
It does? It didn't work for me.
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. |
Christian J |
Sep 17 2006, 05:21 PM
Post
#8
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
But I'm not inclusing the PHP syntax, I told you!
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>'; |
Christian J |
Sep 17 2006, 05:26 PM
Post
#9
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
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. |
Christian J |
Sep 17 2006, 05:30 PM
Post
#10
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
Wonder if the OP is enough confused by now? Maybe we (I) should clean up this thread.
|
pandy |
Sep 17 2006, 05:42 PM
Post
#11
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,731 Joined: 9-August 06 Member No.: 6 |
Double escapes in the JS?
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.. |
Christian J |
Sep 17 2006, 06:10 PM
Post
#12
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
Double escapes in the JS? 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.. Yes ma'm. |
Lo-Fi Version | Time is now: 26th April 2024 - 09:04 AM |