code: public static Object executeScript(JavascriptExecutor jse, String script, Object... parameters) {
          Object result;
          try {
              result = jse.executeScript(script, parameters);
          } catch (WebDriverException e) {
              String msg = e.getMessage();
              if (msg != null && msg.contains("Detected a page unload event; script execution does not work across page loads.")) {
                  // page reloaded while script ran, retry it once
                  result = jse.executeScript(script, parameters);
              } else {
                  throw e;
              }
          }
          return result;
      }
docs: Executes Javascript in browser. If script contains the magic variable 'arguments'
  the parameters will also be passed to the statement. In the latter case the parameters
  must be a number, a boolean, a String, WebElement, or a List of any combination of the above.
  @link http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/JavascriptExecutor.html#executeScript(java.lang.String,%20java.lang.Object...)
  @param script javascript to run.
  @param parameters parameters for the script.
  @return return value from statement.