vendredi 22 septembre 2017

intercept click on link in webkit.webview

excuse my English level ( thank you to systranet.com for the translation )

in a page HTML, by clicking on a link, the page HTML given is displayed.

but how to make for

_open this page in a another tab, with another program ... ?

_if the link points to another thing that one .htm[l], php… (zip, iso,…) how to detect and launch the download? …

it would be necessary to detect the click on one link, to launch the adequate treatment,

and I do not see how to make,

I do not find examples (with vala) …

example : test.vala :

using Gtk;
using WebKit;
/* 
valac --pkg gtk+-3.0 --pkg webkit2gtk-4.0 --pkg posix test.vala && ./test 
*/
int main (string[] args) {
    Gtk.init(ref args);
    var window=new Gtk.Window();
    window.destroy.connect(Gtk.main_quit);
    WebView wv=new WebKit.WebView();
    string url="file://"+Posix.realpath(args[0])+".html";
    wv.load_uri(url);
    window.add(wv);
    window.show_all();
    Gtk.main();
    return 0;
}

test.html :

«html>
    «body>
        «a href='http://ift.tt/2t0DRcj'>searx</a>
        «a href='http://ift.tt/2hmk9mi'>xpad</a>
    «/body>
«/html>


thank you in advance




Aucun commentaire:

Enregistrer un commentaire