Announcement

Collapse
No announcement yet.

Javascript in José embedded browser

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript in José embedded browser

    Ciao José,

    I'm using your cWindow.AddWebBrowserControl wrapper to create UI interface for my editor and interact with user choices.
    So far all is working really well and I will replace many of my UI classic WIN32 dialogs with html/css pages.

    I've problems with Javascript events.
    Seems Javascript is not executed inside embedded control while if I open the same exact page web page in any browser all is fine.

    Maybe there is some options I need to activate in embedded web browser control to let JS script be fired?
    Maybe some security option?

    Thanks a lot
    Eros
    Last edited by Eros Olmi; 26 Jan 2023, 11:00 AM.

  • #2
    You need to have the html page and java script file(s) on disk an load the html page.
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Yes I load a single file from disk.
      Javascript is embedded into html page

      Also tried to put JS code into an external file but always same result: always working in browser but not into embedded browser.

      Found some old info:



      Will try to see there

      Thanks

      Comment


      • #4
        I think problem is related to control events I'm trying to trap.

        My Javascript code is fired by an input text inside the page in the following way:
        Code:
        <input type="text" id="SearchBox" onkeydown="SearchFunction()" placeholder="Search for files ..." title="Type in text to search">
        Javascript function is the following and what it does is hide tables rows not having input text typed inside search box
        But this function is never fired by keyboard input event
        Code:
            <script>
                function SearchFunction() {
        
                    var input, filter, tables, rows, td, i, t, txtValue;
                    input = document.getElementById("SearchBox");
        
                    filter = input.value.toUpperCase();
        
                    document.getElementById("output").innerHTML = "Searching for: " + input.value;
        
                    tables = document.getElementsByClassName("sortable-table");
                    
                    for (t = 0; t < tables.length; t++) {
                    
                        rows = tables[t].getElementsByTagName("tr");
                        
                        for (i = 0; i < rows.length; i++) {
                        
                            if (rows[i].parentNode.localName == "tbody") {
                            
                                txtValue = rows[i].cells[0].innerText;//innerHTML;
        
                                if (txtValue.toUpperCase().indexOf(filter) > -1) {
                                    rows[i].style.display = "";
                                } else {
                                    rows[i].style.display = "none";
                                }
                            }
                        }
                    }
                    
                }
                
            </script>
        ​
        I think keyboard input events are trapped by PowerBasic code and never released to the web page event queue.

        Other Javascript code I add to the page not handling keyboard events is correctly executed.

        Comment


        • #5
          SOLVED

          Reading this post: https://forum.powerbasic.com/forum/j...ndow-and-focus

          I was using DIALOG NEW ... to create main window
          I switched to José CWindow class and using pWindow.CreateWindow ... and its message pump, all is working fine now
          Keyboards events are correctly triggered by Javascript source code

          Comment

          Working...
          X