This topic is locked
[SOLVED]

 Close Browser in Model View

7/18/2011 2:43:45 PM
PHPRunner General questions
H
hsan author

What event / script would I have to use on a button (or link) in order to close browser window within the View Page?

Thanks

C
cgphp 7/18/2011

In the Javascript onLoad event:

$("#button_or_link_id").click(function(e){

window.opener='x';

window.close();

});
H
hsan author 7/18/2011



In the Javascript onLoad event:

$("#button_or_link_id").click(function(e){

window.opener='x';

window.close();

});



Thanks for help, but this did not work. I have modified original button on View Page like this: "<INPUT id=submit2 class=button value="Close" type=button name=submit2>" in html editor. I added this code to JavaScript OnLoad Event for View Page:
$("#submit2").click(function(e){

window.opener='x';

window.close();

});
And it did not work. My View Page is not a popup window, it is regular window where I want user to just review last added record and close browser. What am I doing wrong?
Thanks & Regards

C
cgphp 7/19/2011

You can't close the main window directly. The close() method only works for windows opened with the open() method.

You should load the main window via javascript to do that.

H
hsan author 7/19/2011



You can't close the main window directly. The close() method only works for windows opened with the open() method.

You should load the main window via javascript to do that.


Thanks for the info, it is actually very logical. Your script, slightly changed:
$("#your_button").click(function(e){

window.opener='X';

window.open('','_parent','');

window.close();

});
will close IE but not FF & Others. Just for the info if somebody out there needs it for (maybe) web intranets based on IE.