python webkitgtk xmlhttprequest 文件协议
如何在pywebkit中为file://协议启用xmlhttprequest?
就像Chrome浏览器那样
http://www.google.com/support/forum/p/Chrome/thread?tid=171316324d16747b&hl=en
1 个回答
5
在WebView
上设置enable-file-access-from-file-uris
这个属性:
view = webkit.WebView()
settings = view.get_settings()
settings.set_property('enable-file-access-from-file-uris', 1)
view.open('file://./foo.html')
下面是一个示例文件foo.html
,它会把file://./bar.html
的内容写入到网页的主体部分:
<html>
<head><script type="text/javascript" src="jquery-1.4.4.js"></script></head>
<body><script>
$.ajax({url: 'file://./bar.html', success: function(data) {
document.write(data);
}
});
</script></body></html>