Plugin implemented using JCEF API - How to open hyperlinks in an external browser



I have developed a plugin which uses JCEF api to render the web contents. And i was able to load the web content in to a FileEditor.

When a user click a link from the initial web page, Those pages need to be loaded in a external browser instead of the same FileEditor window. Is there any way that i can accomplish this task using the JCEF api ?

The approach that iam trying is as follows. But currently iam unable to get the Document object of the loaded HTML. Or is there any better way of doing this.

Document document = // get document object using JCEF api ;
NodeList nodeList = document.getElementsByTagName(HYPERLINK_TAG);
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
EventTarget eventTarget = (EventTarget) node;
eventTarget.addEventListener(CLICK_EVENT_TYPE, new EventListener() {
public void handleEvent(Event evt) {
EventTarget target = evt.getCurrentTarget();
HTMLAnchorElement anchorElement = (HTMLAnchorElement) target;
String href = anchorElement.getHref();
// handle opening URL outside JCEF
try {
//open in external browser
} catch (URISyntaxException e) {
}, false);

1 comment
Comment actions Permalink

Please do not crosspost between Slack and this forum.


Post is closed for comments.