onBeforeBrowse not being called for some links?

Having problems with building or using the JCEF Java binding? Ask your questions here.

onBeforeBrowse not being called for some links?

Postby markhen » Thu Jan 26, 2023 9:47 pm

(Thanks to all for the amazing work put into CEF/JCEF!)

I am using JCEF to build an email client. JCEF is working very well for me overall.

However I have an issue with onBeforeBrowse not being called when some links in HTML emails are viewed and clicked.

This seems to be most prevalent for links that are associated with buttons, less prevalent for links that display as underlined text.

In some cases, even though the cursor changes to the "finger/hand" when over the link, clicking doesn't result in a call to onBeforeBrowse.

If I send the same HTML to my system browser the links all work correctly (Chrome 109.0.5414.120 Win11).

My version info is:

JCEF Version: JCEF Version = 108.4.13.305
CEF Version = 108.4.13
Chromium Version = 108.0.5359.125

What could cause CEF to not call onBeforeBrowse ?

TIA

Mark
markhen
Newbie
 
Posts: 6
Joined: Fri Jan 20, 2023 6:49 pm

Re: onBeforeBrowse not being called for some links?

Postby magreenblatt » Thu Jan 26, 2023 10:35 pm

Are you saying that the links don’t work, that onBeforeBrowse is not called, or both? Can you provide an example?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: onBeforeBrowse not being called for some links?

Postby markhen » Fri Jan 27, 2023 1:52 am

Both (some links don't work, onBeforeBrowse is not called for some links).

I will try to put together illustrative example(s) without sharing sensitive or 3rd party content.

Bullets on what I'm doing:

  • I create CefApp, Client and Browser
  • CEF Browser is loaded with email HTML content from a local file using createBrowser()
  • I have overridden onBeforeBrowse():
    • if the URL passed is a local email file it will display in the CEF browser JFrame - and onBeforeBrowse returns false
    • if the URL is HTTP it is passed to the system browser - and onBeforeBrowse returns true
  • CEF Browser is displayed in a JFrame - emails render perfectly
  • Links behave visually as expected - cursor changes, link highlights etc. per the email HTML code
  • Clicking on links in displayed emails I see 2 behaviors:
    • onBeforeBrowse() is called, link URL is passed in correctly, opens in the system browser
    • OR, onBeforeBrowse() is not called when a link is clicked (nothing happens visually or at my app level)
  • The behaviors are not "random", for example:
    • underlined text links in the body of an Apple subscription confirmation email don't call onBeforeBrowse, but underlined text links at the end of the page do
    • none of the links in daily digest emails from LinkedIn result in call to onBeforeBrowse()
    • the "button" links in AT&T survey emails don't call onBeforeBrowse(), but the underlined text links do

As stated in my original post, if I open the local email HTML files directly with the system browser, all links work correctly.

Since the links behave visually as expected (cursor changes etc.) it appears CEF understands the link is a valid link?

Could it be that the mouse click is not detected under certain HTML conditions? That seems a little far fetched?

Thanks -

Mark
markhen
Newbie
 
Posts: 6
Joined: Fri Jan 20, 2023 6:49 pm

Re: onBeforeBrowse not being called for some links?

Postby magreenblatt » Fri Jan 27, 2023 10:15 am

In order for us to assist you, you will need to share the actual HTML or JS that is not navigating as expected when clicked. You are welcome to sanitize any URLs (e.g. replace with example.com provided it maintains the same behavior).
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: onBeforeBrowse not being called for some links?

Postby markhen » Fri Jan 27, 2023 2:29 pm

Thanks, understood. I'll find a useful example email content and revert.

Best regards -

Mark
markhen
Newbie
 
Posts: 6
Joined: Fri Jan 20, 2023 6:49 pm

Re: onBeforeBrowse not being called for some links?

Postby magreenblatt » Wed Feb 01, 2023 9:04 pm

The button link causing you problems has target=“_blank”. That should result in a call to CefRequestHandler.onOpenURLFromTab.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: onBeforeBrowse not being called for some links?

Postby markhen » Thu Feb 02, 2023 1:01 pm

Thank you so much - that was indeed the issue. Now resolved in my application I believe.

Based on your comment I found this older issue (that you commented on) that may help others with similar/same problems:

https://bitbucket.org/chromiumembedded/cef/issues/2028/cefrequesthandler-onopenurlfromtab-gets

Best -

Mark
markhen
Newbie
 
Posts: 6
Joined: Fri Jan 20, 2023 6:49 pm


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 11 guests