* * *

Author Topic: HTMLViewer JavaScript demos problems  (Read 888 times)

JD

  • Hero Member
  • *****
  • Posts: 1703
HTMLViewer JavaScript demos problems
« on: February 10, 2018, 05:40:58 pm »
Hi there,

I want to try the javascript demos included with HTMLViewer (FrameDemJavaScriptUsingBesen and/or FrameDemJavaScriptUsingBesenW).

I've already downloaded the extra Besen files needed by these examples. After much tweaking, I finally compiled them both.

However running both programs has no visible result apart from eating up my CPU.

Has anyone succeeded in using HTMLViewer to display HTML with javascript files.

Thanks,

JD
Windows (10, 7) - Lazarus 1.8/FPC 3.0.4, NewPascal, Delphi
Linux Mint Cinnamon  - Lazarus 1.8/FPC 3.0.4, NewPascal

Indy 10.6 series; mORMot; Zeos 7.2.1; SQLite, Firebird, PostgreSQL & MariaDB; VirtualTreeView 5.5.3 R1

Phil

  • Hero Member
  • *****
  • Posts: 2602
Re: HTMLViewer JavaScript demos problems
« Reply #1 on: February 10, 2018, 05:57:53 pm »
Has anyone succeeded in using HTMLViewer to display HTML with javascript files.

Why not use an actual Web browser-based control instead of ancient stuff like HTMLViewer?

That's the idea behind TWebBrowser.

https://macpgmr.github.io/

JD

  • Hero Member
  • *****
  • Posts: 1703
Re: HTMLViewer JavaScript demos problems
« Reply #2 on: February 10, 2018, 06:22:40 pm »
Has anyone succeeded in using HTMLViewer to display HTML with javascript files.

Why not use an actual Web browser-based control instead of ancient stuff like HTMLViewer?

That's the idea behind TWebBrowser.

https://macpgmr.github.io/

Thanks for the tip Phil. I've downloaded and installed the TWebBrowser component. How does it work? Do you have a demo you can share? I want to be able to display an HTML/JavaScript file like the one at https://developers.google.com/chart/interactive/docs/quick_start

Code: HTML5  [Select]
  1.   <head>
  2.     <!--Load the AJAX API-->
  3.     <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  4.     <script type="text/javascript">
  5.  
  6.       // Load the Visualization API and the corechart package.
  7.       google.charts.load('current', {'packages':['corechart']});
  8.  
  9.       // Set a callback to run when the Google Visualization API is loaded.
  10.       google.charts.setOnLoadCallback(drawChart);
  11.  
  12.       // Callback that creates and populates a data table,
  13.       // instantiates the pie chart, passes in the data and
  14.       // draws it.
  15.       function drawChart() {
  16.  
  17.         // Create the data table.
  18.         var data = new google.visualization.DataTable();
  19.         data.addColumn('string', 'Topping');
  20.         data.addColumn('number', 'Slices');
  21.         data.addRows([
  22.           ['Mushrooms', 3],
  23.           ['Onions', 1],
  24.           ['Olives', 1],
  25.           ['Zucchini', 1],
  26.           ['Pepperoni', 2]
  27.         ]);
  28.  
  29.         // Set chart options
  30.         var options = {'title':'How Much Pizza I Ate Last Night',
  31.                        'width':400,
  32.                        'height':300};
  33.  
  34.         // Instantiate and draw our chart, passing in some options.
  35.         var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
  36.         chart.draw(data, options);
  37.       }
  38.     </script>
  39.   </head>
  40.  
  41.   <body>
  42.     <!--Div that will hold the pie chart-->
  43.     <div id="chart_div"></div>
  44.   </body>
  45. </html>
  46.  

Thanks a lot,

JD
Windows (10, 7) - Lazarus 1.8/FPC 3.0.4, NewPascal, Delphi
Linux Mint Cinnamon  - Lazarus 1.8/FPC 3.0.4, NewPascal

Indy 10.6 series; mORMot; Zeos 7.2.1; SQLite, Firebird, PostgreSQL & MariaDB; VirtualTreeView 5.5.3 R1

Phil

  • Hero Member
  • *****
  • Posts: 2602
Re: HTMLViewer JavaScript demos problems
« Reply #3 on: February 10, 2018, 06:27:11 pm »
Do you have a demo you can share?

Yes, it includes the PasMap app, which is the Laz version of this Xcode app:

https://macpgmr.github.io/MacXPlatform/WebAppOverview_3.html#EmbeddedBrowser



JD

  • Hero Member
  • *****
  • Posts: 1703
Re: HTMLViewer JavaScript demos problems
« Reply #4 on: February 10, 2018, 07:26:04 pm »
Do you have a demo you can share?

Yes, it includes the PasMap app, which is the Laz version of this Xcode app:

https://macpgmr.github.io/MacXPlatform/WebAppOverview_3.html#EmbeddedBrowser

The PasMap app is not working for me. Nothing is displayed in the form.

In addition the following simple example does not work either

Code: Pascal  [Select]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   WebBrowser;
  10.  
  11. type
  12.   { TForm1 }
  13.   TForm1 = class(TForm)
  14.     Button1: TButton;
  15.     WebBrowser1: TWebBrowser;
  16.     procedure Button1Click(Sender: TObject);
  17.     procedure WebBrowser1PageLoaded(Sender: TObject);
  18.     procedure WebBrowser1PageLoadError(Sender: TObject);
  19.   private
  20.  
  21.   public
  22.  
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.lfm}
  31.  
  32. { TForm1 }
  33.  
  34. procedure TForm1.Button1Click(Sender: TObject);
  35. begin
  36.   WebBrowser1.LoadPage('www.microsoft.com');
  37. end;
  38.  
  39. procedure TForm1.WebBrowser1PageLoaded(Sender: TObject);
  40. begin
  41.   ShowMessage('Page loaded successfully');
  42. end;
  43.  
  44. procedure TForm1.WebBrowser1PageLoadError(Sender: TObject);
  45. begin
  46.   ShowMessage('Error loading page');
  47. end;
  48.  
  49. end.
  50.  

I just want something that can display local HTML/JavaScript files created by another application. I don't want to go the Electron route because of bloat and memory consumption of Electron apps.

cheers,

JD
Windows (10, 7) - Lazarus 1.8/FPC 3.0.4, NewPascal, Delphi
Linux Mint Cinnamon  - Lazarus 1.8/FPC 3.0.4, NewPascal

Indy 10.6 series; mORMot; Zeos 7.2.1; SQLite, Firebird, PostgreSQL & MariaDB; VirtualTreeView 5.5.3 R1

Phil

  • Hero Member
  • *****
  • Posts: 2602
Re: HTMLViewer JavaScript demos problems
« Reply #5 on: February 10, 2018, 07:31:42 pm »
The PasMap app is not working for me. Nothing is displayed in the form.

TWebBrowser currently only supports Cocoa and Qt4 widgetsets, as documented in point 1 of readme.txt. Maybe you're using win32?

I just want something that can display local HTML/JavaScript files created by another application. I don't want to go the Electron route because of bloat and memory consumption of Electron apps.

Understood. And agree.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus