Forum Archive

Get current ui.WebView URL

disorientedp

How can I get the URL of the currently loaded page in WebView?

Webmaster4o

Why don't you make a delegate and set a global variable whenever should_start_load is called.

omz
web_view.eval_js('window.location.href')
Webmaster4o

@omz's solution is far more elegant, disregard my answer.

disorientedp

@omz I didn't think of JavaScript. Thanks!

disorientedp

@omz Weird. That always returns a url starting with applewebdata://

omz

@disorientedp Did you use load_html (and not load_url) to load the page perhaps?

dgelessus

I assume the currently displayed page comes from a load_url, not a load_html? The latter doesn't include any location information, so this applewebdata:// URL is probably used as a substitute.

disorientedp

@dgelessus yes, it comes from load_url

omz

Maybe the page hasn't finished loading yet when you call this?

disorientedp

@omz Oh. That worked.