我了解到我可以以 Base64 URL 的形式打开各种文档,如本文最后一行所示。到目前为止,我可以打开一个 HTML 文档,但它包含 JavaScript,我无法执行我的函数rr()
,该函数是通过单击“创建新表单”按钮调用的。我正在使用 Firefox 16 并安装了 NoScript。据我所知,我已经让它允许file://
和`data:URLs。但是不知道为什么点击按钮不能执行该功能,但是从浏览器的地址栏运行就可以执行。我应该检查什么问题或可能的问题?
<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+DQogPHRpdGxlPmFib3V0OjIwMTItMDktMDQ8L3RpdGxlPg0KDQoNCg0KDQogPHNjcmlwdD4NCiBmdW5jdGlvbiBycigpDQogew0KICB2YXIgcj1kb2N1bWVudC5sb2NhdGlvbjsNCiAgICAvL1RoaXMgaXMgdG8gbWFrZSByIHN0b3AgcG9pbnRpbmcNCiAgICAvL3RvIHRoZSBhY3R1YWwgZG9jdW1lbnQubG9jYXRpb24gb2JqZWN0DQogICAgLy8vDQogICAgICByKz0iIjsNCg0KICAgICAgcj1yLnJlcGxhY2UoImRhdGE6dGV4dC9odG1sO2Jhc2U2NCwiLCIiKTsNCiAgICAgIHI9YXRvYihyKTsNCg0KLy8gICAgICByPXIucmVwbGFjZSgvLisvLCJ7fSIpDQogICAgICByPXIucmVwbGFjZShkb2N1bWV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