Home  >  Article  >  Web Front-end  >  Design a program in js so that it can print its own method collection_javascript skills

Design a program in js so that it can print its own method collection_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:16:38808browse
Design a program in js so that it can print itself

[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]


[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]
[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]


[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]

Suddenly this question seems like There is nothing to discuss:

If you want to print all the code, add at the end of the program:
alert(document.getElementsByTagName("script")[0].outerHTML)

If you remove <script></script>
alert(document.getElementsByTagName("script")[0].innerHTML);
If you only print the code of a certain function:
<script>(function(){alert("<script>"+arguments.callee+"()<\/script>")})()</script> <script> function a() { document.write(a, "a()");}a() </script>[Ctrl A select all Note: <script>(function a(){alert("<script>"+a+"()<\/script>")})()</script>If you need to introduce external Js, you need to refresh to execute <script> function AnyCode() { // Any Code } var anyCode = 0; alert(document.getElementsByTagName("script")[0].outerHTML) </script>]
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn