开发者

python webkitgtk xmlhttprequest file protocol

开发者 https://www.devze.com 2023-03-07 11:41 出处:网络
How to enable xmlht开发者_开发百科tprequest for file:// protocol in pywebkit ? just like chrome does

How to enable xmlht开发者_开发百科tprequest for file:// protocol in pywebkit ?

just like chrome does

http://www.google.com/support/forum/p/Chrome/thread?tid=171316324d16747b&hl=en


Set the enable-file-access-from-file-uris property on WebView:

view = webkit.WebView()
settings = view.get_settings()
settings.set_property('enable-file-access-from-file-uris', 1)
view.open('file://./foo.html')

Example file foo.html which writes contents of file://./bar.html into the body:

<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>
0

精彩评论

暂无评论...
验证码 换一张
取 消