<div dir="ltr">Hi, it looks it works now. I edited my code with new lines:<div><div> def __init__(self, url):</div><div> ....<br></div><div> ....<br></div><div> self.jQuery = """ </div>
<div> your javascript code here</div><div> """ </div><div> self.view.loadProgress.connect(self.setProgress)</div><div><br></div><div> def setProgress(self, p):</div><div> self.view.page().mainFrame().evaluateJavaScript(self.jQuery) </div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-01 0:27 GMT+02:00 Peter Irbizon <span dir="ltr"><<a href="mailto:peterirbizon@gmail.com" target="_blank">peterirbizon@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi guys, </div><div><br></div><div>I am using evaluateJavaScript to change some JS values in my case window.navigator. It works pretty well on first visited page <a href="http://something.tld/first.php" target="_blank">http://something.tld/first.php</a> but when I click on any link on that page and go to second.php it stops to be in effect.</div>
<div>How can I do it to stay this javascript in effect for every visited (navigated, clicked) page from my application? </div><div><br></div><div>#!/usr/bin/env python</div><div>#-*- coding:utf-8 -*-</div><div><br></div>
<div>
from PyQt4 import QtCore, QtGui, QtWebKit </div><div><br></div><div>getJsValue = """ </div><div>window.navigator = {</div><div> appCodeName: 'MyApp',</div><div> appName: 'MyNewApp',</div>
<div> vendor: 'MyCompany'</div><div>}</div><div>""" </div><div><br></div><div>class myWindow(QtWebKit.QWebView): </div><div> def __init__(self, parent=None):</div><div> super(myWindow, self).__init__(parent)</div>
<div> </div><div> self.page().mainFrame().evaluateJavaScript(getJsValue)</div><div> </div><div> self.page().mainFrame().addToJavaScriptWindowObject("myWindow", self)</div><div> self.loadFinished.connect(self.on_loadFinished)</div>
<div> self.load(QtCore.QUrl('<a href="http://something.tld/first.php'" target="_blank">http://something.tld/first.php'</a>))</div><div><br></div><div> @QtCore.pyqtSlot(str) </div><div> def showMessage(self, message):</div>
<div> print "Message from website:", message</div><div><br></div><div> @QtCore.pyqtSlot()</div><div> def on_loadFinished(self):</div><div> #self.page().mainFrame().evaluateJavaScript(getJsValue)</div>
<div> pass </div><div><br></div><div>if __name__ == "__main__":</div><div> import sys</div><div><br></div><div> app = QtGui.QApplication(sys.argv)</div><div> app.setApplicationName('myWindow')</div>
<div><br></div><div> main = myWindow()</div><div> main.show()</div><div><br></div><div> sys.exit(app.exec_())</div></div>
</blockquote></div><br></div>