javascript - How can I close the browser window after redirecting to an MS office(word,excel, powerpoint) document automatically opened? -


in web application working on, have long-running processes in charge of getting office documents. open popup window.open takes care of polling server report process status , wait availability of document, , redirect generated document when ready (window.location = the_url_of_the_file).

when redirection happens, depending on user configuration (see microsoft knowledge base), ms office document may opened/embedded directly in internet explorer, or may open file in new instance of office suit.

in latter case, document opens in excel, window caused opening stays there forever.

is there way force window close excel has loaded file ?

i expect somehow related how integration between ie , windows works ...

edit

$.ajax({            async: false,            type: 'post',            datatype: 'json',            url: '/controller/action/' + docid,            data: $('form').serialize(),            success: function (url) {                window.open(url, 'showfile', 'top=25,left=50,width=680,height=400,help=1,status=1,scrollbars=1,toolbars=1,menubar=1,resizable=1',false);        }    }); 

her edocument opened in new word instance , teh teh window remains open after teh document opened.. window should close when file opened in new ms office instance. url location on server pointing document.

this not possible. many reasons:

  1. after change window's location, cannot execute code - you're done
  2. the document opened in new window cannot communicate old window, because not html page , cannot execute javascript there
  3. there no way of telling how document handled. can guess work depending on browser type , os being used, guess. either downloaded, opened in plugin, opened natively in chrome frame (upcoming feature), opened automatically in ms word... possible outcomes endless.

i suggest rethink website logic.

i suggest performing ajax instead of opening new window , use check status of document, , when it's ready, open in new window.

if need open new window that, suggest change document.location of parent window (the 1 you've used open pop up). after close pop up. not redirect page new location open document you've described (however behaviour cannot guaranteed depending on user's setup).


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -