Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有:
self.webview = WebKit.WebView() self.scrolledwindow = self.builder.get_object("scrolledwindow") self.scrolledwindow.add(self.webview) self.webview.open(ADVSEARCHURI) self.webview.show()
它正在显示整个网站,但我只想显示特定 div 的内容并隐藏其余部分。最简单的方法是什么?
使用execute_script您可以将 javascript 注入 webview。因此,只需像往常一样显示或隐藏 div:
execute_script
js_code = "document.getElementById('foo').style.display = 'None';" self.webview.execute_script(js_code)