Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-20-2012, 07:58 AM   PM User | #1
Jian0203
New Coder

 
Join Date: Mar 2012
Posts: 47
Thanks: 2
Thanked 0 Times in 0 Posts
Jian0203 is an unknown quantity at this point
Force browser to close and reopen.

Hi, I am new here, it's nice to meet you guys.

I am writting a javascript that need to force the user to close the current browser and then restart automatically again after some operation. Here is the case :

The user will retrieve a file from the server and save it in the local drive. After that, the browser will automatically open the .pdf saved with the browser(IE) but not Adode reader.

If the user wants to update the previous saved .pdf in the local drive, they will need the user to close the opened file(saved .pdf) so that new updated .pdf can be replaced to the old .pdf file. So, I need to implement a function that force the browser to close, then copy and replace the old file, then reopen the file(new and updated) again.

Is there any possible way of doing this ? Please provide me some idea. I have tried to look for informations online but I just got no luck. Failed with the coding provided. Thanks in advance.

P/S : The file need to be closed in order to replace it with a new one. The platform using is Windows.
Jian0203 is offline   Reply With Quote
Old 03-20-2012, 09:04 AM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,465
Thanks: 0
Thanked 499 Times in 491 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
You can't force someone to do anything with JavaScript - they have complete control and can turn off JavaScript completely, turn it off selectively for your page, or simply add their own script to the browser that overrides yours.

In any case JavaScript is only able to close a browser window that was opened using JavaScript and where the original page is still displayed there.

Also when using window.open in JavaScript you still have no control over whether it opens in a new window, a new tab, or simply overwrites the current page - as that too can be selected by the person who owns the browser.

From your PS it sounds like you simply want to do a forced reload of the current page in which case you just need location.reload(true); (the true forces it to reload from the server - with false it would reload from the browser cache).
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/

Last edited by felgall; 03-20-2012 at 09:06 AM..
felgall is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:03 PM.


Advertisement
Log in to turn off these ads.