What does this mean: “[removed]('<scr'+'ipt… ”?

前端 未结 6 1617
一向
一向 2020-12-03 07:25

I\'ve seen this on every Yahoo! news page, at the bottom of the source code,
and failed to understand why they break the script word like that.
<

6条回答
  •  -上瘾入骨i
    2020-12-03 08:10

    Consider this simplified example:

     something");
    
    

    The browser's HTML parser would see the within the JavaScript string and interpret that as the end of the script element.

    The HTML parser doesn't know about JavaScript syntax - all it knows is that the .

    (It also knows that you can't have nested in your example.)

提交回复
热议问题