Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect and cancel anchor links/ajax calls #1211

Closed
javiercampos opened this issue Aug 19, 2015 · 6 comments
Closed

Detect and cancel anchor links/ajax calls #1211

javiercampos opened this issue Aug 19, 2015 · 6 comments
Milestone

Comments

@javiercampos
Copy link

I have a series of anchor links that use JavaScript (with AJAX) to open content (SPA style). I'm trying to emulate ctrl+click or middle click behaviour, so I was doing this in OnBeforeBrowse:

if (Control.ModifierKeys.HasFlag(Keys.Control) 
        && request.TransitionType == TransitionType.LinkClicked)
{
  MainForm.OpenChildWindow(new Uri(request.Url));
  return true;
}

However OnBeforeBrowse is never called for anchor-with-javascript links (except if the anchor link is the same as the currently loaded URL for some reason), so I'm not sure how I could detect those. I tried OnBeforeResourceLoad but that only happens when it's actually reading the response of the Ajax call, so the actual link that the user clicked can't be detected (or I can't find how).

Ctrl+click (or middle click) works fine in Chrome in this same web-application on those links.

Any ideas?

@amaitland
Copy link
Member

I understand your keen to see your problem resolved, posting on GitHub, stackoverflow and the google group in the space of an hour is a little much don't you think?

The 2357 branch of CEF introduces a the method OnOpenUrlFromTab, which sounds like what your looking for.

https://github.com/cefsharp/CefSharp/blob/master/CefSharp/IRequestHandler.cs#L43

The feature is currently only available in the master branch

@amaitland amaitland added this to the 43.0.0 milestone Aug 19, 2015
@javiercampos
Copy link
Author

Sorry about duplicating the issue, yes, it might be a bit too much, I reckon, I just had a bit of urgency with this issue since the client should be going into production today and it was the only issue left resolving (I posted after several hours trying things and looking at the CefSharp source code and I realize I was a bit desesperate).

Will try recompiling the latest CefSharp and test the OnOpenUrlFromTab method, thanks

@amaitland
Copy link
Member

since the client should be going into production today

Do you use javascript binding in your app? If so then master is not stable enough for production use

@amaitland
Copy link
Member

Although if your using an SPA, you might be lucky. Major issue with master is #1203

There are also issues #1144 with PDF and #799 (comment) related to Flash. Just so you know what your getting into.

@javiercampos
Copy link
Author

I do, but just for something really basic (not doing any JS work other than registering an object which can be checked from the rest of the JS in the web-app), not doing any kind of interaction with this object. Will try the #1203 issue and if it doesn't work, I think I can use a workaround for it in the meantime (opening links in new tabs should be more important than this actually).

Not using PDF or Flash so #1144 and #779 should not be an issue, but thanks for the warning. I'll test the app throughoutly before going to production, thanks for the warnings.

Will get back to this issue if I solve it with master and close it with the solution, thanks again

@javiercampos
Copy link
Author

This is exactly what I was looking for, and works just fine, so I'll close the issue with this comment. Need to test the JS binding issues but again, I can work around it if it doesn't work for the time being. If I get some free time after this going into production I'll try to look at the issue and contribute.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants