Why is this script element broken into multiple calls to document.write ()?

Possible duplicate:
Why break the <script> tag when writing it using document.write ()?

I often saw the following statement:

document.write("<scr");
document.write("ipt language=\"Javascript\" type=\"text/javascript\" src=\"source url\"></scr");
document.write("ipt>");

What is the advantage of this? Why don't people write the whole script as shown below?

document.write("<script ");
+3
source share
5 answers

This may help you:

http://www.webmasterworld.com/forum91/2913.htm

Depending on the browser, the number of other previous javascript, and how well the general code is formed, is done to prevent the analyzer from interpreting and tags as executable code and not as a string that needs to be written.

, , script script.

+3

, , , .

CDATA:

STYLE SCRIPT CDATA , CDATA - . . "</" ( ) . .

</ :

document.write("<script language=\"Javascript\" type=\"text/javascript\" src=\"source url\"><" + "/script>");
+2

. , , , , <script> .

.

+1

, script?

:
. , , , .

, , <!-- <script> blargh </script> //-->

0

, - , script . - "<script", , .

, -.

0

Source: https://habr.com/ru/post/1756721/


All Articles