HTML-тэг для предотвращения HTML-тэгов, которые будут выполняться?

Для полноты вопросом является конкретный случай сортирующая схема , который Knuth ( Искусство Программирования , vol 3) покрытия в мельчайших подробностях. классическая статья K.E. Дозатор на предмете краток и стоит считать.

6
задан Gumbo 9 October 2009 в 12:12
поделиться

8 ответов

You are going to have to do it manually.

Here you have the full encoding table. The most commonly used codes are:

Character  Entity Number  Entity Name  Description
"          "          "       quotation mark
'          '          '       apostrophe (does not work in IE)
&          &          &        ampersand
<          &#60;          &lt;         less-than
>          &#62;          &gt;         greater-than
7
ответ дан 8 December 2019 в 04:54
поделиться

This:

The html code for &lt; is &amp;lt;

Renders as:

The html code for < is <

The basic strategy is to escape the & as &

9
ответ дан 8 December 2019 в 04:54
поделиться

Я полагаю, вы не хотите, чтобы объект отображался? Если вы хотите отобразить & lt; , вам нужно будет использовать объект для амперсанда: & amp; .

4
ответ дан 8 December 2019 в 04:54
поделиться

In this case, you DON'T need to encode it. Try this one:

<xmp> html < &lt; </xmp>

I'm not sure about cross browsers support, but works on IE7,FF3,Chrome3

2
ответ дан 8 December 2019 в 04:54
поделиться

The html code for < is <

That is, type < is &lt;.

1
ответ дан 8 December 2019 в 04:54
поделиться

If you have access to server side scripting capabilities, you might be able to use utility functions of that platform. For example, in PHP you might use the htmlentities function to your advantage:

echo htmlentities("The html code for < is &lt;");
1
ответ дан 8 December 2019 в 04:54
поделиться

Вы можете использовать

 & lt; 
последовательность

0
ответ дан 8 December 2019 в 04:54
поделиться

You need to encode it. For example, '<' = '<'

Here is the list.

So in your case it will end up like this:

The html code for &lt; is &amp; l t ;
0
ответ дан 8 December 2019 в 04:54
поделиться