1

如何在 pywebkit 中为 file:// 协议启用 xmlhttprequest?

就像铬一样

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

4

1 回答 1

5

enable-file-access-from-file-uris属性设置为WebView

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>
于 2011-05-19T21:56:31.970 回答