0

I have some HTML where parts of the content are created from GWT. Assume that I have no access to the GWT code, how can I get access to this to modify the content in javascript in the JSP?

My aim is to change DIV text that was genereated with GWT code and I want to change this in the JSP using JavaScript with something like

document.getElementById("title").innerHTML = "new title";

The problem that I have, is the GWT DIVS created seem to be loaded after the body of the JSP has loaded, meaning when I want to access document.getElementById("title").innerHTML it doesn't see it, until after the page has loaded?

Neil Walker
  • 6,400
  • 14
  • 57
  • 86
  • 1
    Then [wait for the page to load](http://stackoverflow.com/questions/807878/javascript-that-executes-after-page-load)? – Baz Apr 24 '14 at 13:52

1 Answers1

0

My aim is to change DIV text that was genereated with GWT code

You can achieve it using GWT JSNI that is similar to JavaScript code.

For detailed descriptions and samples please have a look at Writing Native JavaScript Methods


Create a JSNI method in your client side JAVA code and call it after creating div.

public static native void setTitle(String newTitle)
/*-{
    var title = $wnd.document.createElement("title");
    title.innerHTML = "new title";      

}-*/;
Braj
  • 46,415
  • 5
  • 60
  • 76