1
當我調用webkit_web_view_load_string()將html內容加載到 的webkitview時,webkit始終拒絕加載html內容中引用的本地文件或資源(css,javascript,images)。使用webkitgtk加載資源+
注意:我使用GResource將資源加載到二進制文件中? 這是一個例子:
GBytes *data;
GResource *resource;
GByteArray* gbarray; resource = one_file_get_resource();
.
。 。 。
g_resources_register (resource);
data = g_resource_lookup_data (resource,"/com/test/resources/index.html", G_RESOURCE_LOOKUP_FLAGS_NONE,NULL);
gbarray = g_bytes_unref_to_array(data);
const gchar* data_char = gbarray->data;
。 。 。
webkit_web_view_load_string(webView, data_char, NULL, NULL,"");
這是GResources我的xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/test">
<file>resources/index.html</file>
<file>resources/style.css</file>
</gresource>
</gresources>
現在我的問題是,index.html的加載,但沒有css文件。我沒有造型我的HTML文件!我該如何解決這個問題,謝謝?!
使用file://肯定會工作,但我想要的是在構建期間將所有資源與可擴展應用程序一起嵌入。這使我能夠從任何其他PC運行應用程序,而無需將資源從某個地方轉移到另一個地方,這就是爲什麼我使用了GResoures Framework。 –