Handling of javascript window.open() in the browser
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:
- the first 2 cases (PDF upload and Zipfile upload) do not cause anything to happen, and there is no error message.
- 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.
@jiit, thanks for tagging; I completely forgot that!
juiceme ( 2016-09-30 13:48:00 +0300 )edit