[Gambas-user] A question about WebView

Jorge Carrión shordi at ...626...
Mon Oct 17 06:33:08 CEST 2016


Hi Gianluigi:

Sorry for the delay but this has been a hard (or good!) weekend for me, no
computers at all... 😀😎.
I hope the problems of the whilwind are fixed yet in your town.
I've seen your code and it's a good javascript based solution but I'm
afraid I'm not able to implement it in my proyect. This is the first time I
deal with webview component and I prefer to do it whith Gambas.

Essentialy the tricky solution I've found is keep the external urls (href
tags) of the html text in a string[] and then  to replace all  with "blind
inner links" (<a href="url/#n") where n is index of the usrls string[].
Then the webview acts on that links showing the appropiate cursor undeline
font, etc. but doesn't go anywhere if you click on it. Just show a balloon
with de original url of the link.
When you read de .html property of the control all the replacements are
translated to the original Urls, so you have the html edited.

I don't know if this is usefull for you, but is what I've done. I'll put it
on gamba's farm soon, I think.

Best Regards

2016-10-14 22:39 GMT+02:00 Gianluigi <bagonergi at ...626...>:

> Lucky you Jorge,
> if here in Genoa, today not there had been a whirlwind (no electricity and
> discarge notebook :-( ) I (too) would have answered so:
> '------------------------------
> Public Sub Form_Open()
>
>   WebView1.HTML = MakeHtml()
>
> End
>
> Private Function MakeHtml() As String
>
>   Dim sHtml As String
>
>   sHtml = "<!DOCTYPE html>" & "\n"
>   sHtml &= "<html>" & "\n"
>   sHtml &= "<body>" & "\n"
>   sHtml &= "<a id=\"myAnchor\" href=\"http://gambaswiki.org/wiki\"
> onclick=\"myFunction(event)\">Documentation</a>" & "\n"
>   sHtml &= "<script>" & "\n"
>   sHtml &= "function myFunction(event) {" & "\n"
>   sHtml &= "event.preventDefault();" & "\n"
>   sHtml &= "document.getElementById(\"myAnchor\").innerHTML =
> \"Canceled\";" & "\n"
>   sHtml &= "}" & "\n"
>   sHtml &= "</script>" & "\n"
>   sHtml &= "</body>" & "\n"
>   sHtml &= "</html>" & "\n"
>
>   Return sHtml
>
> End
>
> Public Sub Form_Close()
>
>   Print WebView1.HTML
>
> End
> '--------------------------------------
> It is no good code, but I had come this way.
> As I'm starting to study WebView I wanted to ask you, this is how it should
> be implemented the script.
> Otherwise?
> Can you give me any suggestions?
>
> Regards
> Gianluigi
>
> 2016-10-14 17:25 GMT+02:00 Jorge Carrión <shordi at ...626...>:
>
> > Well... I think that I've found a workaround only with gambas. (It's a
> > little tricky but it works),
> >
> > Thank you for the answers.
> >
> > Best Regards
> >
> > 2016-10-14 15:03 GMT+02:00 Moviga Technologies <moviga at ...3488...>:
> >
> > > There might be a way to do it with Gambas, but you can use javascript's
> > > preventDefault()
> > >
> > > http://www.w3schools.com/jsref/event_preventdefault.asp
> > >
> > >
> > > Den 14. okt. 2016 12:15, skrev Jorge Carrión:
> > > > I'm trying to do a control like textEdit, but allowing with links and
> > > > images, based on webBrowser example.
> > > >
> > > > All is done and works fine, but if I create a link (<a href.. etc)
> and
> > I
> > > > click on it the webview, naturally, follows the link and I loose all
> > the
> > > > changes on the page.
> > > >
> > > > I want prevent that behaviour in the way that if user clik on a link
> > and
> > > > the editable property is true, the webview doesn't follow the link.
> > > >
> > > > Hope this will be more clear.
> > > >
> > > > Best Regards
> > > >
> > > > 2016-10-14 11:39 GMT+02:00 Gianluigi <bagonergi at ...626...>:
> > > >
> > > >> Hello Jorge,
> > > >> I do not understand the question, could you be more specific?
> > > >> Thank you
> > > >> Gianluigi
> > > >>
> > > >> 2016-10-13 18:29 GMT+02:00 Jorge Carrión <shordi at ...626...>:
> > > >>
> > > >>> Is there a way to stop the follow of links in webview when webview
> is
> > > in
> > > >>> "edit mode" (editable=true)?
> > > >>>
> > > >>> Best Regards
> > > >>> ------------------------------------------------------------
> > > >>> ------------------
> > > >>> Check out the vibrant tech community on one of the world's most
> > > >>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> > > >>> _______________________________________________
> > > >>> Gambas-user mailing list
> > > >>> Gambas-user at lists.sourceforge.net
> > > >>> https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >>>
> > > >> ------------------------------------------------------------
> > > >> ------------------
> > > >> Check out the vibrant tech community on one of the world's most
> > > >> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> > > >> _______________________________________________
> > > >> Gambas-user mailing list
> > > >> Gambas-user at lists.sourceforge.net
> > > >> https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >>
> > > > ------------------------------------------------------------
> > > ------------------
> > > > Check out the vibrant tech community on one of the world's most
> > > > engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> > > > _______________________________________________
> > > > Gambas-user mailing list
> > > > Gambas-user at lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> > >
> > > ------------------------------------------------------------
> > > ------------------
> > > Check out the vibrant tech community on one of the world's most
> > > engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> > > _______________________________________________
> > > Gambas-user mailing list
> > > Gambas-user at lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list