Open file link with application on user click [dup

2019-08-26 01:41发布

问题:

This question already has an answer here:

  • Open Google Earth and load specific KML file when user clicks link on web page 1 answer

In my website i have a link to kml file .

When a user clicks on this link ,I want to open this kml file with google earth application.

In android we can do it by using intent and providing content type.

How to do the same is desktop ? NO But it will not solve the problem.

Is there way to ask for user consent if yes open using script? Can i run any client side script to do this.

回答1:

As mentioned on the answer you have linked to:

You generally can't run arbitrary program on the client machine from a web page. With or without consent. You can only do this by installing a browser plug-in after the user consent or otherwise asking the user for actions.
Allowing this will be a security hazard.

You can use standard web page actions. But then the result can depend on client side user configuration.

It is also mention in the linked answer that you can use the web base Google Earth. And of course you can use some simple client side script to ask confirmation for that if you still like to.