/*
CSSHttpRequest
Copyright 2008 nb.io - http://nb.io/
Licensed under Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.html
*/
(function(){
var chr = window.CSSHttpRequest = {};
chr.id = 0;
chr.requests = {};
chr.MATCH_ORDINAL = /#c(\d+)/;
chr.MATCH_URL = /url\("?data\:[^,]*,([^")]+)"?\)/;
chr.get = function(url, callback) {
var id = ++chr.id;
var iframe = document.createElement( "iframe" );
iframe.style.position = "absolute";
iframe.style.left = iframe.style.top = "-1000px";
iframe.style.width = iframe.style.height = 0;
document.documentElement.appendChild(iframe);
var r = chr.requests[id] = {
id: id,
iframe: iframe,
document: iframe.contentDocument || iframe.contentWindow.document,
callback: callback
};
r.document.open("text/html", false);
r.document.write("<html><head>");
r.document.write("<link rel='stylesheet' type='text/css' media='print, csshttprequest' href='" + chr.escapeHTML(url) + "' />");
r.document.write("</head><body>");
r.document.write("<script type='text/javascript'>");
r.document.write("(function(){var w = window; var p = w.parent; p.CSSHttpRequest.sandbox(w); w.onload = function(){p.CSSHttpRequest.callback('" + id + "');};})();");
r.document.write("</script>");
r.document.write("</body></html>");
r.document.close();
};
chr.sandbox = function(w) {
};
chr.callback = function(id) {
var r = chr.requests[id];
var data = chr.parse(r);
r.callback(data);
window.setTimeout(function() {
var r = chr.requests[id];
try { r.iframe.parentElement.removeChild(r.iframe); } catch(e) {};
delete chr.requests[id];
}, 0);
};
chr.parse = function(r) {
var data = [];
// Safari, IE and same-domain Firefox
try {
var rules = r.document.styleSheets[0].cssRules || r.document.styleSheets[0].rules;
for(var i = 0; i < rules.length; i++) {
try {
var r = rules.item ? rules.item(i) : rules[i];
var ord = r.selectorText.match(chr.MATCH_ORDINAL)[1];
var val = r.style.backgroundImage.match(chr.MATCH_URL)[1];
data[ord] = val;
} catch(e) {}
}
}
// catch same-domain exception
catch(e) {
r.document.getElementsByTagName("link")[0].setAttribute("media", "screen");
var x = r.document.createElement("div");
x.innerHTML = "foo";
r.document.body.appendChild(x);
var ord = 0;
try {
while(1) {
x.id = "c" + ord;
var style = r.document.defaultView.getComputedStyle(x, null);
var bg = style["background-image"] || style.backgroundImage || style.getPropertyValue("background-image");
var val = bg.match(chr.MATCH_URL)[1];
data[ord] = val;
ord++;
}
} catch(e) {}
}
return decodeURIComponent(data.join(""));
};
chr.escapeHTML = function(s) {
return s.replace(/([<>&""''])/g,
function(m, c) {
switch(c) {
case "<": return "<";
case ">": return ">";
case "&": return "&";
case '"': return """;
case "'": return "'";
}
return c;
});
};
})();
分享到:
相关推荐
Aspnet-crossdomain-aspnet.zip,一个简单的跨域(跨源)解决方案,通过HTML在多个网站之间发送数据。不需要javascript。使用以下技术堆栈:c,asp.net mvc,asp.net会话状态。跨域asp.net,asp.net是一个开源的web...
PHPCMS V9二次开发教程官方版 文件目录结构 根目录 | – api 接口文件目录 | – caches 缓存文件...| – crossdomain.xml FLASH跨域传输文件 | – robots.txt 搜索引擎蜘蛛限制配置文件 | – favicon.ico 系统icon图标
PHPCMS二次开发教程 文件目录结构 ...| – crossdomain.xml FLASH跨域传输文件 | – robots.txt 搜索引擎蜘蛛限制配置文件 | – favicon.ico 系统icon图标 ...........................................
•Cross domain uploads (Cross-site uploads). •How to add Drop zone effects. •How to display Extended progress information. •Drag and drop uploads from another web page •Fixing Safari hanging on ...
Writing conflict-free JavaScript, HTML, and CSS Making cross-domain requests from the browser How to overcome third-party cookie limitations Security vulnerabilities of third-party applications ...
├── crossdomain.xml ├── css │ ├── main.css │ └── normalize.css ├── favicon.ico ├── humans.txt ├── img │ ├── startup │ │ ├── startup-retina-4in.png │ │ ├── ...
默认的根设置文件(robots.txt,humans.txt,crossdomain.xml,.editorconfig和.htaccess) 特定平台的资源(Craft CMS) 要求 节点/ NPM 部署方式 部署由管理。 GIT master分支更新并推送到后,该站点将自动部署。 ...
在静态域名根目录下添加 crossdomain.xml 注:这个配置并不是必须的,打包工具生成的目标文件,可以直接通过script标签引用。 ##大概了解 1.更加贴合nodejs中模块的编写方式,无需define包裹。 2.任何后缀的文本文件...
Flex-Puzzle 仿美图秀秀在线拼图(Flex版) 1.API接口参见美图秀秀 2.配置项可见puzzle.js ...loadPhoto的图片地址服务器上需要有crossdomain.xml文件,否则图片只可以显示不可以进行像素级操作(截图,保存等)
Hosting and domain names 194 Download at Wow! eBook WWW.WOWEBOOK.COM Table of Contents [ vi ] Uploading your shop 196 Setting up a new database 196 Importing your WordPress database 197 Uploading ...
5.3.4 crossdomain.xml与Flash的“沙盒” 125 5.3.5 ExternalInterface 126 5.3.6 FLASH XSS 126 5.3.7 Microsoft Edge中的Flash ActiveX 130 5.4 浏览器的沙盒 131 5.4.1 受限令牌 132 5.4.2 完整性级别与IE...
Cross-scripting...779 Accessing loaded media as data.783 Loading data786 Loading embedded content from SWF files imported into a security domain..788 Working with legacy content..789 Setting ...
(2)Considering cross-domain data interaction problem, reasons of it were pointed out and analysed. LocalStorage was overrided based on HTML5 storage technics, and local sqlite was used to maintain ...
$crossFrame:true, $preLoad:false, $dpPath:"", doubleCalendar:false, enableKeyboard:true, enableInputMask:true, autoUpdateOnChanged:null, weekMethod:"ISO8601", position:{}, lang:"auto", skin:"default",...
在ASP.Net中两种利用CSS实现多界面的方法 如何在客户端调用服务端代码 页面一postback,它就显示页面的最顶端,怎样让它定位在某一位置? 如何保证页面刷新后的滚动条位置 清除网页历史记录,屏蔽后退按钮! 如何传值...