What is the matter with script-targeted URLs?

前端 未结 1 515
面向向阳花
面向向阳花 2021-01-07 20:47

I\'m using JSHint, and it got the following error:

Script URL.

Which I noticed that happened because on this particular line there is a str

相关标签:
1条回答
  • 2021-01-07 21:27

    javascript: URLs are part of 'eval is evil'.

    In order to execute the javascript: URL, the browser must fire up a JS parser and parse the text of the URL.
    This is a slow and costly process.

    Also, assembling javascript: URLs (or other strings that contain source code) is a tricky task which is prone to XSS vulnerabilities.

    Finally, mixing code and URLs violates the separation of content and behavior (code).

    0 讨论(0)
提交回复
热议问题