OK here is the soluction I came up with:
Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(NativePreviewEvent
event) {
if (event.getTypeInt() == Event.ONCLICK) {
// do something with the keycode
//
doSomething(event.getNativeEvent().getKeyCode());
if(com.google.gwt.dom.client.Element.is(event.getNativeEvent
().getEventTarget())){
Element targetElement =
(Element) Element.as(event.getNativeEvent
().getEventTarget());
if("a".equalsIgnoreCase(getTagName(targetElement))) {
//String hostURL =
GWT.getHostPageBaseURL();
String href =
DOM.getElementAttribute
((com.google.gwt.user.client.Element) targetElement, "href");
//
check href against hostURL to see if the link is realitive or absolute
then do whatever you want.
//event.cancel();
}
}
}
}
});
__________________________________________
native String getTagName(Element element)
/*-{
return element.tagName;
}-*/;
On Aug 31, 3:36 pm, Chris Bailey <[email protected]> wrote:
> I'm working on a social type site which I will make different versions
> depending on the device (mobile, desktop, etc...) and I want all the
> links to be just standard href hyperlinks. I know it's possible but
> how would you in GWT check a hyperlink before it is executed??
>
> My Goal is to check to see if the link is realitive then if it is I
> can just run my own function that will not change the location of the
> user's page but instead get the data the link is pointing to and parse
> it. If it's not a realitive link I will assume the person is trying to
> get off the page and either (based on user settings) change the whole
> page to that link or open a new window of that link.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---