0

I am trying to block URLs with a certain keyword in a JavaFX webview. So far, I have tried using webEngine.locationProperty().addListener() to listen for a change in state. While this is successful in blocking the URL, it unfortunately leaves the locationProperty set to the value that I am trying to block. This causes problems for links that use references on the page.

Two solutions I have tried for setting locationProperty back to its correct value:

  1. Calling webEngine.load(). This causes the page to refresh and the user loses work.
  2. Calling webEngine.getHistory().go(0). As it says in the documentation, this does nothing.

I can think of two general ways to solve this problem:

  1. Find a place earlier in the chain of properties than locationProperty that gets changed to listen.
  2. Figure out a way to change locationProperty back to its correct value without reloading the page. (I think this might be possible through reflection which I've been trying to avoid up to this point.)

Do either of these solutions sound reasonable and if so what is the best way to implement them?

fdsa
  • 1,379
  • 1
  • 12
  • 27
  • I think this is somewhat different but I will work on some of the other answers tomorrow to see if I can incorporate them. – fdsa Oct 15 '14 at 01:49
  • @jewelsea Not the same as I need to figure out how to alter the current location – fdsa Oct 16 '14 at 01:06

0 Answers0