제목 속성에서 큰 따옴표를 이스케이프 처리하는 방법
앵커의 제목 속성에 큰 따옴표가 포함 된 문자열을 사용하려고합니다. 지금까지 나는 이것을 시도했다.
<a href=".." title="Some \"text\"">Some text</a>
<!-- The title looks like `Some \` --!>
과
<a href=".." title="Some "text"">Some text</a>
<!-- The title looks like `Some ` --!>
작은 따옴표를 사용 하는 것은 옵션 이 아닙니다 .
이 변형-
<a href=".." title="Some "text"">Some text</a>
정확하고 예상대로 작동합니다. 렌더링 된 페이지에 일반 따옴표가 표시됩니다.
다음 은 archive.org의 캐시 된 페이지에서 가져온 HTML 이스케이프 문자 스 니펫입니다 .
< | less than sign <
@ | at sign @
] | right bracket ]
{ | left curly brace {
} | right curly brace }
… | ellipsis …
‡ | double dagger ‡
’ | right single quote ’
” | right double quote ”
– | short dash –
™ | trademark ™
¢ | cent sign ¢
¥ | yen sign ¥
© | copyright sign ©
¬ | logical not sign ¬
° | degree sign °
² | superscript 2 ²
¹ | superscript 1 ¹
¼ | fraction 1/4 ¼
¾ | fraction 3/4 ¾
÷ | division sign ÷
” | right double quote ”
> | greater than sign >
[ | left bracket [
` | back apostrophe `
| | vertical bar |
~ | tilde ~
† | dagger †
‘ | left single quote ‘
“ | left double quote “
• | bullet •
— | longer dash —
¡ | inverted exclamation point ¡
£ | pound sign £
¦ | broken vertical bar ¦
« | double left than sign «
® | registered trademark sign ®
± | plus or minus sign ±
³ | superscript 3 ³
» | double greater-than sign »
½ | fraction 1/2 ½
¿ | inverted question mark ¿
“ | left double quote “
— | dash —
이스케이프 코드 "
를 대신 사용할 수도 있습니다 "
.
사용 "
하는 방법입니다. 두 번째 코드 스 니펫을 시도했으며 Firefox와 Internet Explorer에서 모두 작동합니다.
It may work with any character from the HTML Escape character list, but I had the same problem with a Java project. I used StringEscapeUtils.escapeHTML("Testing \" <br> <p>")
and the title was <a href=".." title="Test" <br> <p>">Testing</a>
.
It only worked for me when I changed the StringEscapeUtils to StringEscapeUtils.escapeJavascript("Testing \" <br> <p>")
and it worked in every browser.
There is at least one situation where using single quotes will not work and that is if you are creating the markup "on the fly" from JavaScript. You use single quotes to contain the string and then any property in the markup can have double quotes for its value.
Perhaps you can use JavaScript to solve your cross-browser problem. It uses a different escape mechanism, one with which you're obviously already familiar:
(reference-to-the-tag).title = "Some \"text\"";
It doesn't strictly separate the functions of HTML, JavaScript, and CSS the way folks want you to nowadays, but whom do you need to make happy? Your users or techies you don't know?
You can use this PHP code to list special characters...
<table border="1"><?php for($i=33;$i<9000;$i++)echo "<tr><td>&#$i;<td>&#".$i.";"; ?></table>
참고URL : https://stackoverflow.com/questions/3752769/how-to-escape-double-quotes-in-a-title-attribute
'Programing' 카테고리의 다른 글
React Native를 사용할 때 데이터를 저장하는 옵션은 무엇입니까? (0) | 2020.05.19 |
---|---|
Chrome에서 자동 완성을 실행하는 방법은 무엇입니까? (0) | 2020.05.19 |
“파일 끝에 줄 바꿈 없음”컴파일러 경고 (0) | 2020.05.19 |
Java java.lang.Class에 해당하는 스칼라 (0) | 2020.05.19 |
robots.txt에서 상대 사이트 맵 URL을 사용할 수 있습니까? (0) | 2020.05.19 |