Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: How to access Dom objects on a web view section

  1. #1
    Senior Member
    Join Date
    Feb 2012
    Posts
    1,214

    How to access Dom objects on a web view section

    Hi,

    In a desktop application, I have a web view section and a canvas section.
    How can I reference an id in the webview section from the canvas section?

    I seem to recall having to use Lianja.window, but I am drawing a blank at the moment.

    Thanks.

    Herb

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,771
    Hi Herb,

    The WebView section has an evaluate() method which lets you execute JavaScript inside it.
    http://www.lianja.com/doc/index.php/Webview
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,771
    So...

    Just evaluate() document.getElementById('name').value;
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #4
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,881
    Hi Herb,
    I also tried to do something like that, but then I decided to do everything from webview .. for you it would be possible?

    Name:  2016-08-30 14_47_45-Lianja App Builder v3.0 [martinelli_articoli] - UTF-8 - cogema - Licensed to.jpg
Views: 79
Size:  43.6 KB

  5. #5
    Senior Member
    Join Date
    Feb 2012
    Posts
    1,214
    Hi Barry,

    What I am looking for is access to the webview objects from outside the webview.

    Meaning - If I want to change the innerhtml of an item in the webview from a canvas section how can that be accomplished.

    I guess another way to ask the same question is what is the hierarchy of webview in the LOM/DOM

    something like Lianja.page1.document.getElementById("Title").inne rHTML = "New Title!";

    Thanks.

    Herb

  6. #6
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,771
    Hi Herb,

    All you need to do is get a reference to the WebView section in Lianja.

    myview = Lianja.getElementByID("page1.section1").webview

    If you define a JavaScript function in your WebView HTML using a <script> tag. It can take an ID and the innerhtml that you want to replace.

    You can then call the evaluate() function to execute your JavaScript function.

    myview.evaluate("updateHtml('someid', 'newhtml')")
    Last edited by barrymavin; 2016-08-30 at 09:24.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  7. #7
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,881
    then it would be interesting to see what comes out ... :-)

  8. #8
    Senior Member
    Join Date
    Feb 2012
    Posts
    1,214
    Hi Barry,

    I'm probably missing something simple.

    Here is a simple jssp webview with a single function.
    <%@ Language=JavaScript %>
    <html>
    <body>

    <div id ="buttondiv">
    <button id = "button1" onclick =sayhi()>Hi</button>
    </div>
    </body>

    <script>
    function sayhi(){
    Lianja.showMessage("Hi")
    }

    </script>
    </html>

    In the vfp console, I tried the following.
    mycall = Lianja.get("page1.section1")
    Lianja.evaluate(mycall.sayhi())


    I have also tried mycall = Lianja.get("page1.section1").webview.

    Thanks

    Herb

  9. #9
    Senior Member
    Join Date
    Feb 2012
    Posts
    1,214
    I also tried it with quoutes

  10. #10
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,771
    Both your onclick and your evaluate need to be enclosed in quotes and you call evaluate() in the WebView not the Lianja system object.

    Mycall.evaluate("sayhi()")
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

Page 1 of 2 12 LastLast

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us