B4J Question Scroll to an anchor

TomDuncan

Active Member
Licensed User
Longtime User
Hi All.
I have a button which I need to scroll to a given anchor on the current page.
This works well in normal html pages for me but in this situation..

B4X:
Sub mainblog_click (Params As Map)
    If Params.IsInitialized Then
        If Params.Get("target") = "" Then Return
        Dim s As String = Params.Get("target")
        Log("comments: " & s)
        If s.Contains("read_") Then
            Dim blog_id As String = s.Replace("read_","")
            ws.GetElementById("blog_show_body").SetHtml(show_blog_post(blog_id))
            ' now move to that anchor location'
        End If
        If s.Contains("leave_") Then leave_comment(s)
        If s.Contains("submit_") Then leave_comment(s)
    End If
End Sub

After the div element if set with the html data I want to scroll to that location.
I think what is happening is the on-click event is being taken by b4j.

Tom
 

TomDuncan

Active Member
Licensed User
Longtime User
Thanks for that.
I used
B4X:
ws.Eval("window.location = arguments[0]", Array As Object("#blog_show_body"))
and it works like a charm.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…