Thanks for the quick response! I actually don't have to worry about
security because what I am linking to is hosted locally. All I needed
to get was the url of the iframe at its current state and also the
page title.
You have helped me a lot -- I now am using JSNI to get this
information. I am having problems with one simple thing however. I
cannot seem to pass the javascript strings back to my Java code (so I
don't think that would be a question for javascript forums). Here are
the relevant functions I am using:
public void testJS(String URL) {
System.out.println("URL: " + URL.toString());
}
public native void setupJS(PageViewer x) /*-{
$wnd.iframeLoad = function (iframe) {
var content;
//contentDocument is Firefox, contentWindow is IE
if(iframe.contentDocument != undefined) {
content = iframe.contentDocument;
} else {
content = iframe.contentWindow;
}
var url = content.location;
var title = content.document.title;
alert(url);
alert(title);
//This line does not work!
x.@com.aarnott.client.PageViewer::testJS(Ljava/lang/String;)(url);
};
}-*/;
The iframe has the attribute: onload='iframeLoad(this);' --> I know
that works because I can alert the URL and title on page change.
The instance of PageViewer x does work because I tested an empty
function called testJS2:
public void testJS2() {
System.out.println("got here...");
}
And it worked with the line:
x.@com.aarnott.client.PageViewer::testJS2()();
Any ideas why my testJS function does not work? It obviously has
something to do with passing parameters, but I think I am following
the JSNI instructions correctly (from
http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.JavaScriptNativeInterface.html).
Thanks,
Andrew