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

nwjs 0.20 opening magnet url from iframe works only once #5680

Closed
garfield69 opened this issue Feb 1, 2017 · 3 comments
Closed

nwjs 0.20 opening magnet url from iframe works only once #5680

garfield69 opened this issue Feb 1, 2017 · 3 comments
Assignees

Comments

@garfield69
Copy link

NWJS SDK 0.20.0 (Chromium 56) Windows 7 ia32

Opening a magnet url (for example: magnet:?xt=urn:btih:72383bfbcd0438045f7a75f59ad793747159afff&dn=Ubuntu+Desktop+16.04+LTS by using an iframe, appears to work only once.
It seems I cannot open the magnet url again without first performing a reload.
Yet using nw.Shell.openExternal I can open the same magnet every time.
Also, the same iframe code from within the Chrome 56 Browser works every time.
example code:

<!DOCTYPE html>
<html>
  <head>
    <title>Standalone Development</title>
  </head>
  <body style="width: 100%; height: 100%;">
    <p>Click the link below to open magnet via iframe</p>
    <u onclick="open_Url_Via_Iframe()">open magnet via iframe</u>
    <p>Now click on the link a 2nd time,</br>note that it does not seem to work any more,</br>until you do a right-click reload App.</br>Note that the same iframe code,</br>on a chromium 56 Browser works every time.</br>Also, if you open the magnet,</br>using nw.shell you can open it,</br>as many times as you like.</br>click on the link below to try it out.</p>
    <u onclick="open_Url_Via_Shell()">open magnet via shell</u>
    <script>
    function open_Url_Via_Iframe() {
      var d = document.createElement('iframe');
      d.id = 'url_' + new Date().getTime();
      d.style.visibility = 'hidden';
      d.src = "magnet:?xt=urn:btih:72383bfbcd0438045f7a75f59ad793747159afff&dn=Ubuntu+Desktop+16.04+LTS";
      document.body.appendChild(d);
      var dTimer = setInterval(function () {
          var dDoc = d.contentDocument || d.contentWindow.document;
          if (dDoc.readyState == 'complete') {
              document.body.removeChild(d);
              clearInterval(dTimer);
              return;
          }
      }, 1000);
    };
    function open_Url_Via_Shell() {
      nw.Shell.openExternal("magnet:?xt=urn:btih:72383bfbcd0438045f7a75f59ad793747159afff&dn=Ubuntu+Desktop+16.04+LTS");
    };
    </script>
  </body>
</html>

I have prepared an test package for you to play with, should you find it useful.
pre-requisites:

nwjs-sdk-v0.20.0-win-ia32\index.html
nwjs-sdk-v0.20.0-win-ia32\package.json
nwjs-sdk-v0.20.0-win-ia32\_locales\angular-locale_en.js
nwjs-sdk-v0.20.0-win-ia32\_locales\en\messages.json
@Christywl
Copy link
Contributor

I can reproduce this issue on Windows and Linux.
Environment:
NW: 0.20.2-sdk
OS: Windows 10 x86 and Linux 14.04

@rogerwang
Copy link
Member

The root reason is that we're a Chrome App, which is a little different than the browser. Will fix it soon.

@rogerwang
Copy link
Member

This is fixed in git and will be available in the next nightly build.

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

No branches or pull requests

3 participants