JavaScript代码不在Base64'd文档中执行

时间:2012-09-05 08:43:51

标签: javascript html base64 execution

我了解到我可以将所有类型的文档打开为Base64 URL,如本文最后一行所示。到目前为止,我可以打开一个HTML文档,但它包含JavaScript,我无法执行我的函数rr(),通过单击“创建新表单”按钮调用该函数。我正在使用Firefox 16并安装了NoScript。据我所知,我已经允许file://和`data:URL。但我不知道为什么我不能通过单击按钮来执行该功能,但如果我从浏览器的地址栏运行它,我可以执行它。我应该检查什么问题或可能出现的问题?

<html>
    <title>about:2012-09-04</title>
    <script>
        function rr() {
            var r=document.location;
            //This is to make r stop pointing
            //to the actual document.location object

            r+="";
            r=r.replace("data:text/html;base64,","");
            r=atob(r);
            //r=r.replace(/.+/,"{}")

            r=r.replace(document.title, "about:"+document.getElementById("datetitle").value);
            r="data:text/html;base64,"+btoa(r);

            window.open(r,"_blank");
            document.getElementById("urlnew").value=r;
        }
    </script>
    <body>
        <form target='_blank' action='http://google.com/search' method='get'>
            <input type='text' name='q' />
            <input type='hidden' name='tbs' value='qdr:d' />
            <input type='submit' />
        </form>
        <br /><br />
        ____________________________________
        <br />
        Date: <input type="text" id="datetitle" /><br />
        URL: <input type="text" length="25" id="urlnew" /><br />
        <input type="button" onclick="javascript:rr()" value="Create New Form" />
    </body>
</html>

和base64编码:

<code>data:text/html;base64,77u/PGh0bWw+DQogPHRpdGxlPmFib3V0OjIwMTItMDktMDQ8L3RpdGxlPg0KDQoNCg0KDQogPHNjcmlwdD4NCiBmdW5jdGlvbiBycigpDQogew0KICB2YXIgcj1kb2N1bWVudC5sb2NhdGlvbjsNCiAgICAvL1RoaXMgaXMgdG8gbWFrZSByIHN0b3AgcG9pbnRpbmcNCiAgICAvL3RvIHRoZSBhY3R1YWwgZG9jdW1lbnQubG9jYXRpb24gb2JqZWN0DQogICAgLy8vDQogICAgICByKz0iIjsNCg0KICAgICAgcj1yLnJlcGxhY2UoImRhdGE6dGV4dC9odG1sO2Jhc2U2NCwiLCIiKTsNCiAgICAgIHI9YXRv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