Ask / Submit
2

Handling of javascript window.open() in the browser

asked 2016-09-30 10:58:02 +0200

juiceme gravatar image

updated 2016-09-30 11:35:38 +0200

jiit gravatar image

I have a web application that needs to show/push content to the user by opening a new tab / new window. This works in desktop browsers, at least Firefox, Chrome and Safari but seems not to open anything in the Sailfish Browser.

The client-side code is like this;

// Server pushes a PDF to client via websocket, PDF gets rendered in a new tab
if(receivable.type == "pdfUpload") {
    var pdfData = atob(JSON.parse(decrypt(receivable.content, sessionPassword)));
    window.open("data:application/pdf," + escape(pdfData));
}

and this

// Server pushes zipped invoices to client via websocket, prompting use to save/open
if(receivable.type == "zipUpload") {
    var zipData = atob(JSON.parse(decrypt(receivable.content, sessionPassword)));
    window.open("data:application/zip," + escape(zipData));
}

and this

// Server pushes helptext html to client via wabsocket, it gets rendered in a new window
 if(receivable.type == "helpText") {
    var helpText = atob(JSON.parse(decrypt(receivable.content, sessionPassword)));
    var wnd = window.document.open("about:blank", "", "scrollbars=yes");
    wnd.document.write(decodeURIComponent(escape(helpText)));
    wnd.document.close();
}

Does Sailfish browser support content pushing to new tab/window at all, or if so how to activate and use the feature?

When I start the browser from command line and try to access my application here are the results on console:

  1. the first 2 cases (PDF upload and Zipfile upload) do not cause anything to happen, and there is no error message.
  2. the last case produces an error "JavaScript error: http://site.domain/pantterilasku#, line 169: wnd is null"

The line 169 refers to the line "wnd.document.write(decodeURIComponent(escape(helpText)));" in the above snippet.

edit retag flag offensive close delete

Comments

@jiit, thanks for tagging; I completely forgot that!

juiceme ( 2016-09-30 13:48:00 +0200 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2016-10-01 10:11:48 +0200

DaveRo gravatar image

updated 2016-10-01 10:13:26 +0200

I just did a quick experiment. I created a bookmarklet:

javascript:window.open("http://www.example.org");

I injected this into a site. On Firefox on Android it asked if I wanted to open a popup and then opened it.

On Jolla C 2.0.2.51 it displays 'null' - which looks like the value of the failed open.

I poked about in about:config to see whether popups are disabled; there are some likely-looking settings but I couldn't make it work.

So I think it doesn't work, but may be connected with popup-blocking.

edit flag offensive delete publish link more

Comments

Thanks, most probably you are right and it just isn't implemented in the UI.

juiceme ( 2016-10-01 11:19:18 +0200 )edit
1

I would post an issue and see if the developer comments: https://github.com/sailfishos/sailfish-browser/issues

It might also be related to about:blank which doesn't work either and seems to be involved in window.open - see my closed issue 508 (revad=me).

DaveRo ( 2016-10-01 12:25:02 +0200 )edit

I opened an issue about it; https://github.com/sailfishos/sailfish-browser/issues/517

juiceme ( 2016-10-02 21:39:14 +0200 )edit
Login/Signup to Answer

Question tools

Follow
2 followers

Stats

Asked: 2016-09-30 10:58:02 +0200

Seen: 741 times

Last updated: Oct 01 '16