Kirix Support Forums

JavaScript problem

Please post all general questions, comments, bug reports, and any other wxWebConnect feedback here.

JavaScript problem

Postby tiger.public on Mon Aug 10, 2009 4:52 am

When I call the wxWebController::Execute(...), there's no result, and I test it. Then I found that, this line of code:

ns_smartptr<nsIScriptSecurityManager> security_manager;
security_manager = nsGetService("@mozilla.org/scriptsecuritymanager;1");

get an empty object of nsIScriptSecurityManager.

Please send me email if you have any idea of this problem. (tiger.public@gmail.com)

Thanks a lot!
tiger.public
Registered User
 
Posts: 1
Joined: Mon Aug 10, 2009 1:07 am

Re: JavaScript problem

Postby Aaron on Wed Aug 12, 2009 11:06 pm

wxWebControl::Execute() invokes a JavaScript function in the web content that's loaded in the web control. So, make sure this function is properly defined in the content you're loading, and then you should be able to call it with Execute().

For example, suppose you define a JavaScript function in your webpage as follows:

Code: Select all
function ShowMessage(message)
{
    alert(message);
}


You could then invoke it as follows:

Code: Select all
// TODO: create instance of wxWebConnect called m_browser

wxString message = wxT("Hello, World");
m_browser>Execute(wxString::Format(wxT("ShowMessage('%s');"), message.c_str()));
Aaron Williams
Kirix Support Team
User avatar
Aaron
Kirix Support Team
 
Posts: 120
Joined: Fri Dec 16, 2005 3:01 pm

Re: JavaScript problem

Postby qbin on Thu Aug 13, 2009 5:00 am

Test html page:
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
<script type="text/javascript" language="JavaScript">
  function ShowMessage(message)
{
    alert(message);
}
</script>
  <meta http-equiv="content-type" content="text/html; charset=windows-1251">
  <title></title>
  </head>
  <body>
  <form action="http://*****/1.php" method="POST">
  <input name="login" value="vovanchig" />
  <input name="password" type="password" value="123" />
  <input type="submit" name="smb" value="submit" />
  </form>
  </body>
</html>

then I use execute(how you write up), program crashed. What something wrong?
qbin
Registered User
 
Posts: 10
Joined: Thu Jul 30, 2009 8:05 am

Re: JavaScript problem

Postby Ben on Thu Aug 13, 2009 10:40 am

Hi there,

Are you using a different version of Xulrunner? What's the version number you are using?

Ben
Ben Williams
Kirix Support Team
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Re: JavaScript problem

Postby qbin on Thu Aug 13, 2009 2:23 pm

Xulrunner 1.8.1.3
From link in this site.
qbin
Registered User
 
Posts: 10
Joined: Thu Jul 30, 2009 8:05 am

Re: JavaScript problem

Postby lodle on Mon Nov 30, 2009 2:19 am

Also getting this issue with xul runner 1.9. The sample from Mozilla works fine but cant get WebControl to work.
lodle
Registered User
 
Posts: 2
Joined: Mon Nov 30, 2009 1:59 am

Return to wxWebConnect Questions, Thoughts & Feedback