HTML版自产生程式(Quine)

自产生程式(Quine),它以哲学家奎恩命名,指的是输出结果为程式自身源码的程式。能够直接读取自己源码、读入使用者输入或空白的程式一般都不视为自产生程式。

这种东西的产生应该纯粹是处于娱乐而没有太大的实际意义,它的就像用3D打印机打印出一台3D打印机的逻辑。

看着十分有趣,我也DIY了一个HTML版的Quine,代码如下:

<!-- Error 404: Page Not Found @ WWW.ZIVERS.COM -->

<html>
<head><title>Error 404 Page Not Found</title></head>

<body><pre><script language="JavaScript1.7">
var a = new Array("%26lt;!-- Error 404: Page Not Found @ WWW.ZIVERS.COM --%26",
"gt;%0A%0A%26lt;html%26gt;%0A%26lt;head%26gt;%26lt;title%26gt;Error 404 Page ",
"Not Found%26lt;/title%26gt;%26lt;/head%26gt;%0A%0A%26lt;body%26gt;%26lt;pre%",
"26gt;%26lt;script language=%22JavaScript1.7%22%26gt;%0Avar a = new Array(%22",
"%22),%0Ac = unescape(a.join(''));%0Adocument.write(c.substring(0,232)+a.join",
"('%22,%5Cn%22')+c.substring(232));%0A%26lt;/script%26gt;%26lt;/pre%26gt;%26l",
"t;/body%26gt;%0A%26lt;/html%26gt;%0A%0A%26lt;!-- %3Ca href='http://www.ziver",
"s.com/404.html'%3EA Quine 404 Page Made By Henry @WWW.ZIVERS.COM%3C/a%3E --%",
"26gt;"),
c = unescape(a.join(''));
document.write(c.substring(0,232)+a.join('",\n"')+c.substring(232));
</script></pre></body>
</html>

<!-- A Quine 404 Page Made By Henry @WWW.ZIVERS.COM -->

定义了一个404页面:Demo

暂无评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注