ncarlos / clickonceforchrome

Automatically exported from code.google.com/p/clickonceforchrome
0 stars 0 forks source link

Clicking on the clickonce link causes the web page to be refreshed #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When I click on a clickonce link, the clickonce application starts as expected, 
but the web page containing the link is also refreshed...

This does not happen in firefox of internet explorer.

Original issue reported on code.google.com by rek...@gmail.com on 7 Oct 2010 at 6:34

GoogleCodeExporter commented 8 years ago
Thanks for reporting this.  The reason it causes a refresh is because the 
plugin is a mime type handler so the browser actually tries to navigate to the 
.application.  The extension grabs the URL from the navigation and actually 
tells the browser to go back.

When I have some spare cycles I'll see if I can find a way to cancel the 
navigation sooner and avoid the refresh.  Unfortunately I have a feeling that 
by the time the plugin gets called it might already be too late.

Original comment by erichard...@gmail.com on 11 Oct 2010 at 5:43

GoogleCodeExporter commented 8 years ago
Still no news about this issue ?

Original comment by rek...@gmail.com on 10 Dec 2010 at 2:36

GoogleCodeExporter commented 8 years ago
The crux of the problem is that once an NPAPI plugin is activated the browser 
has committed itself to doing a navigation.

The sequence of activation goes something like this:
NP_Initialize // I don't have the .application URL yet
NP_GetEntryPoints // Still no URL
NPP_New // This is the earlier that I get the URL - however if I launch the 
ClickOnce app and then return an error - instead of canceling the navigation 
chrome shows a "Plugin not found" error page.
NPP_NewStream // If I error here the download stops but chrome has already 
created a new HWND and shown it so the navigation is done.
NPP_Write
NPP_DestroyStream

So we're back where we started.  I let the download complete in chrome so that 
I know the browser isn't blocked from downloading from that site and then start 
the ClickOnce launcher (which will actually re-download the .application).

The only work around that I can see at this point would be to change how this 
extension works entirely.  Instead of registering a NPAPI mime type handler the 
plug-in would expose a method to javascript - then the extension would inject 
some javascript onto *every page* which would scan and rewrite any .application 
links to call back through javascript to the plugin directly.  I'm not sure 
running a script on every page is worth it to find and fix the few sites using 
ClickOnce and prevent the refresh.

If you're willing to do the development and submit a patch I'd be happy to 
accept it but I don't have much interest in doing it myself.

Original comment by erichard...@gmail.com on 25 Jan 2011 at 4:42

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I experimented with this a bit more last weekend and found a way to work around 
the refresh.  However it involves injecting some javascript on to every page 
and installing a top level click handler - then loading the plug-in, invoking 
the .application and canceling the click navigation.

The solution feels like a lot of added complexity to fix an issue that only 3 
people have starred.  How strongly do you 3 feel about the issue?

Original comment by erichard...@gmail.com on 9 May 2011 at 8:03

GoogleCodeExporter commented 8 years ago
Well, for me, its an all or nothing issue, if no solution is found, the 
clickonce plugin for chrome is in my particular case quite useless... maybe you 
can provide it as an option which can be turned on or off (I'm ok with it being 
by default disabled)

Original comment by rek...@gmail.com on 9 May 2011 at 8:10

GoogleCodeExporter commented 8 years ago
I checked in a change to expose a scriptable interface on the plugin.  I was 
originally thinking about injecting the following script code into every page 
but that felt a little bit intrusive for a feature that most people probably 
don't use daily.  With this change though you can inject this script or 
something similar (or use an iframe like issue #3) on your own site. 

<script type="text/javascript">
    // To automatically redirect all .application links to the scriptable plugin hook the document click function
    document.onclick = function(e)
    {
        e = e || window.event;
        var element = e.target || e.srcElement;

        if (element.tagName == 'A' && element.href.match(/\.application$/))
        {
            var embed = document.createElement('embed');
            embed.setAttribute('type', 'application/x-ms-application');
            embed.setAttribute('width', 0);
            embed.setAttribute('height', 0);
            // Have to add the embed to the document for it
            // to actually instantiate.
            document.body.appendChild(embed);
            embed.launchClickOnce(element.href);
            // Don't remove the embed right away b/c it can
            // cancel the download of the .application.
            return false;
        }
    }
</script>

A sample/test script: 
http://code.google.com/p/clickonceforchrome/source/browse/sample.html

Original comment by erichard...@gmail.com on 21 May 2011 at 8:21

GoogleCodeExporter commented 8 years ago
Marking this as fixed.  Let me know if this isn't working for some reason.

Original comment by erichard...@gmail.com on 22 May 2011 at 3:24

GoogleCodeExporter commented 8 years ago
works great !!! thx

Original comment by rek...@gmail.com on 23 May 2011 at 5:42

GoogleCodeExporter commented 8 years ago
Had same problem. Suggested solution in #8 worked for me.
The only thing was that I had to remove the $ in the .match to support 
parameters.

Although the issue is only starred by 4 people now, it occurs at a lot of 
end-users. In future it will be more and more common to attach devices like 
medical devices. In my case it was a spirometer.

Original comment by nielsste...@gmail.com on 3 Jul 2014 at 8:31