javascript - jquery not working in PyQt -


i writing small desktop app in pyqt python has qweb view browser. adding functionality browser when user select text using mouse , right click , press show xpath javascript executed find xpath. here code :

@pyqtslot() def slotshowxpath(self):  text = self.selectedtext() if not text:     qmessagebox.information(self,"information","no text selected") else:     frame = self.page().mainframe().documentelement()     #print frame.tohtml()     #abc = frame.document()     #abc.evaluatejavascript("alert('"+self.page().selectedhtml()+"');")     frame.evaluatejavascript("""var data = window.getselection().anchornode.parentnode; getxpath(data);      function getxpath( element ){     alert(element);     var xpath = '';     ( ; (element && element.nodetype) == 1; element = element.parentnode )     {     var id = $(element.parentnode).children(element.tagname).index(element) + 1;     id > 1 ? (id = '[' + id + ']') : (id = '');     xpath = '/' + element.tagname.tolowercase() + id + xpath;        }        alert(xpath);        return xpath;            }"""         ) 

this query working till $(element.parentnode).children not working $(element.parentnode).children(element.tagname).index(element) + 1, can me in fixing issue?

actually problem alert statement inside query.its not getting executed inside when tried outside javascript after returning value, start working


Comments

Popular posts from this blog

ios - Memory not freeing up after popping viewcontroller using ARC -

mouseevent - Catch mouse event on tree widget item in QTreeWidget -

Java JSoup error fetching URL -