June 6, 2011

Adilek Adilek
Lab Rat
5 posts

evaluateJavaScript problem on QML

 

Hi.

Why this code not works?

  1. webView.evaluateJavaScript("document.onclick=myfunc;function myfunc(){alert('salam')}")

The following works well.

  1. settings.javascriptEnabled is set to true. webView.evaluateJavaScript("alert('salam')")

3 replies

June 7, 2011

apap_ apap_
Lab Rat
40 posts

declare your javascript function before calling it :

  1. webView.evaluateJavaScript("function myfunc(){alert('salam')};document.onclick=myfunc;");

June 7, 2011

Adilek Adilek
Lab Rat
5 posts

Same problem.

June 7, 2011

Adilek Adilek
Lab Rat
5 posts

I solved. The problem was that I called this function on onUrlChanged event. I put it to onLoadingFinished. Now it works well.

 
  ‹‹ How to clean ListModel data from a ListView, when model changes?[SOLVED/not an issue]      can’t import QtWebKit build debuggers helpers ››

You must log in to post a reply. Not a member yet? Register here!