hello
can you plase check the example in your help pdf file "TMSFMXPackDevGuide.pdf" page 109?
after the component update 3.1, executescript has problem?
executescript(javascript_function); ---> not working
executescript(directly write the javascript code); --> working
here is the example
<!DOCTYPE html>
<html>
<body>
<h1>My First JavaScript</h1>
<p>Click Date to display current day, date, and time.</p>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = Date();
}
</script>
</body>
</html>
The code used to display the date from a button click:
TMSFMXWebBrowser1.ExecuteJavascript('displayDate();');
Pieter
(Pieter)
2
Hi,
The javascript function needs to be defined as inside the HTML sample.
We will fix this in the documentation.
function displayDate() {<o:p></o:p>
document.getElementById("demo").innerHTML = Date();
}
Kind Regards,
Pieter
ok this is true. but can you please check that this fixed example is working?
<!DOCTYPE html>
<html>
<body>
<h1>My First JavaScript</h1>
<p>Click Date to display current day, date, and time.</p>
<p id="demo"></p>
<script>
function displayDate() {<o:p style="margin: 0px; padding: 0px; border: 0px; font-weight: inherit; font-style: inherit; font-family: inherit;"></o:p>
document.getElementById("demo").innerHTML = Date();<o:p style="margin: 0px; padding: 0px; border: 0px; font-weight: inherit; font-style: inherit; font-family: inherit;"></o:p>
}
</script>
</body>
</html>
The code used to display the date from a button click:
TMSFMXWebBrowser1.ExecuteJavascript('displayDate();');
Pieter
(Pieter)
4
Hi,
Yes the fixed sample is working, but we have tested this here in Windows as you didn't specify the platform you are using?
Kind Regards,
Pieter
Pieter
(Pieter)
6
We have tested this here on Android as well and are able to successfully call the javascript function 'displayDate();' With the following code:
procedure TForm1.Button1Click(Sender: TObject);
begin
TMSFMXWebBrowser1.ExecuteJavascript('displayDate();');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
TMSFMXWebBrowser1.LoadHTML('<!DOCTYPE html>'+
'<html><body><h1>My First JavaScript</h1>'+
'<p>Click Date to display current day, date, and time.</p>'+
'<p id="demo"></p>'+
'<script>function displayDate() {'+
'document.getElementById("demo").innerHTML = Date();'+
'}'+
'</script>'+
'</body>'+
'</html>');
end;
cen you please test with parameter like
function changefont(fontsize) {
$('body').css('font-size',fontsize);
}
Did you test it? And if you experience an issue with it, please provide details about what exact problem you encounter.
yes i cant successful with javascript with parameter at android
function changefont(fontsize) {
$('body').css('font-size',fontsize);
}
TMSFMXWebBrowser1.ExecuteJavascript('changefont("48");');
sorry for that
it is my mistake
i used "on document ready" beginning of scripts.
thank you for your help
$(document).ready(function() {
thank you for your help