且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在当前页面中定义弹出窗口Source?

更新时间:2023-12-01 20:14:58

是的,这是可能的。您可以在页面内声明各种资源的内容。这对于缓存和其他一些东西是不好的,但如果您希望使用纯文本格式共享资源,或者希望保留该页面中页面所需的所有资源,则这可能很有用。





请参阅此处,了解用于促进此类资源的方案的说明。 http://en.wikipedia.org/wiki/Data_URI_scheme [ ^ ]



特别注意格式,如指定在我链接到的页面的第5部分。



示例(来自上面的链接)



Yes, it is possible. You can declare the contents of all kinds of resources inside the page. This is bad for caching and a few other things, though can be useful if you wish to share resource using a text-only format, or would like to keep all resources needed by a page in that page.


See here for an explanation of the scheme used to facilitate this type of resource. http://en.wikipedia.org/wiki/Data_URI_scheme[^]

Pay particular attention to the Format, as specified in Section 5 of the page I linked to.

Example (from above link)

window.open('data:text/html;charset=utf-8,' +
    encodeURIComponent( // Escape for URL formatting
        '<!DOCTYPE html>'+
        '<html lang="en">'+
        '<head><title>Embedded Window</title></head>'+
        '<body><h1>42</h1></body>'+
        '</html>'
    )
);