Answer the question
In order to leave comments, you need to log in
Catch url and follow it in webview?
Hey!
We load a document into the webview, you need to find the url in it and follow it.
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker.State;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
/*from w w w . j a v a2s . c o m*/
public class Main extends Application {
public static void main(String[] args) {
Application.launch(args);
}
private Scene scene;
@Override
public void start(Stage stage) {
WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
webEngine.getLoadWorker().stateProperty().addListener(
new ChangeListener<State>() {
public void changed(ObservableValue ov, State oldState, State newState) {
if (newState == State.SUCCEEDED) {
}
}
});
webEngine.load("https://mail.ru");
scene = new Scene(browser,1024,600, Color.web("#666970"));
stage.setScene(scene);
stage.show();
}
}
if (newState == State.SUCCEEDED) {
webEngine.executeScript("document.getElementById('ph_mail').click()");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question