Closed christiangenco closed 10 years ago
Hmm, this doesn't seem to load WS callbacks in the new html page.
In glass2.html
, for example, I have the line:
WS.sound('SUCCESS');
But on navigating to glass2.html
with window.location.href="glass2.html"
from glass.html
, the success sound doesn't play.
Hi Christian,
Thanks. It is possible that this would work, but could you revise the PR with a version that compiles and then test it? You didn't import WebViewClient, so I assume you could not have compiled or tested this?
Thanks
Oops - updated. I'm working from a heavily modified local fork and just pushed the relevant bits through Github's online editor.
It definitely makes window.location.href="glass2.html"
work, but I'm still having trouble figuring out how to reconnect the WS callbacks to the new page. Any suggestions?
Ahh I figured it out! I needed to be using Utils.getEventBus().post(new ScriptEvent(path));
(where path = (new File(Utils.dataPath() + "scripting/" + filename)).getAbsolutePath()
), which I set up as a JavascriptInterface
method.
Now from within HTML, I can change the view by calling:
WS.loadUrl('glass2.html');
If anyone else is interested in doing this, contact me and I'll assemble a pull request. It's just enough friction for me not to muster the impetus to push here by my own volition :p
I think making it work the way you tried the first time would be better. Something like this http://stackoverflow.com/questions/2378800/clicking-urls-opens-default-browser should work. If you feel like looking into that as a solution, we'd love to have your PR.
When trying to navigate to a new URL like this:
I was getting the error:
I found the way to fix this on a StackOverflow comment.