Skip to content

Handle links that use custom protocols - "mailto:" for example. #80

Open
@GoogleCodeExporter

Description

@GoogleCodeExporter
Currently when you click on a "mailto:" link you will see an error:

    "Failed to load URL mailto:[email protected]? ... with error (-302)."

It can be fixed in CefRequestHandler::OnBeforeBrowse(). In a similar way that 
external links are handled. A system default browser is launched when there is 
"external_navigation" settings.json option set to false. The call to 
ShellExecute(open) should work for the mailto links as well.

We should introduce "external_protocols" option in settings.json. This would be 
a list of protocols that will be handled by OS. For example ["mailto"] by 
default.

The fix for now would be to attach a global event listener for the "onclick" 
event using document.addEventListener(). The target element that was clicked 
should be checked whether its "href" attribute starts with a "mailto:" link. If 
so, you should handle the event and call a php script through AJAX. The php 
script should execute Windows system command to open the default email client. 
In C++ the code would look like:

    ShellExecute(NULL, L"open", "mailto:[email protected]", NULL, NULL, SW_SHOWNORMAL);

Unfortunately I don't know a way to make such system call from within php. This 
doesn't work for me:

    system("mailto:[email protected]")
    system("start [email protected]")

Though, launching url in default browser works fine with the start command:

    system("start http://www.google.com/")

Maybe it is feasible with the use of the system() command, but that would 
require further investigation.

Original issue reported on code.google.com by [email protected] on 7 Feb 2014 at 3:36

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions