taisel / GameBoy-Online

JavaScript GameBoy Color emulator.
http://taisel.github.io/GameBoy-Online/
593 stars 175 forks source link

open link. #25

Open pavelbv2 opened 5 years ago

pavelbv2 commented 5 years ago

Hello.

How can I open ROM via a link from a site, rather than opening it from a computer. Maybe somewhere here you can fix it - if (typeof this.files != "undefined") { try { if (this.files.length >= 1) { cout("Reading the local file \"" + this.files[0].name + "\"", 0); try { //Gecko 1.9.2+ (Standard Method) var binaryHandle = new FileReader(); binaryHandle.onload = function () { if (this.readyState == 2) { cout("file loaded.", 0); try { initPlayer(); start(mainCanvas, this.result); } catch (error) { alert(error.message + " file: " + error.fileName + " line: " + error.lineNumber); } } else { cout("loading file, please wait...", 0); } } binaryHandle.readAsBinaryString(this.files[this.files.length - 1]); }

ahmedsaee468 commented 2 years ago

Hello.

How can I open ROM via a link from a site, rather than opening it from a computer.

Maybe somewhere here you can fix it -

` if (typeof this.files != "undefined") {

      try {

          if (this.files.length >= 1) {

              cout("Reading the local file \"" + this.files[0].name + "\"", 0);

              try {

                  //Gecko 1.9.2+ (Standard Method)

                  var binaryHandle = new FileReader();

                  binaryHandle.onload = function () {

                      if (this.readyState == 2) {

                          cout("file loaded.", 0);

                          try {

                              initPlayer();

                              start(mainCanvas, this.result);

                          }

                          catch (error) {

                              alert(error.message + " file: " + error.fileName + " line: " + error.lineNumber);

                          }

                      }

                      else {

                          cout("loading file, please wait...", 0);

                      }

                  }

                  binaryHandle.readAsBinaryString(this.files[this.files.length - 1]);

              }`
Darklife12354 commented 1 year ago

Uh anyone figure this out yet

dominicOT commented 1 year ago

@ahmedsaee468

var romLink = "https://example.com/path/to/romfile.rom";

var link = document.createElement("a");
link.style.display = "none";
link.href = romLink;

// add the link to the body of the document
document.body.appendChild(link);

// here you simulate a click event that would prompt the download
link.click();

// to remove the link from the document body
document.body.removeChild(link);

this can only be achievable if you have the ROM file link already