You should be using some kind of custom made popups and dialogue like
http://umairj.com/27/how-to-create-simple-modal-dialogue-using-jquery/
http://www.jquery4u.com/windows/14-jquery-modal-dialog-boxes/
Jquery or Javascript alternative to window.open to get a different target
searching for an alternative to window.open without opening a window lol
alternate method for window.open
Modernized version of window.open() API
I have this function to ask for a basic password and then load a php script:
function passwd(){
var password = prompt('Enter the password');
if(password.toLowerCase() == "password"){
window.open("./files/restart-calibre.php")
}else{
alert("incorrect password!!");
}
}
As I am very new to this all of it is copied from stackoverflow.
Now this code does open the script in a new page which I do not want. What would be the best way to achieve this?
Your code is a little bit weird so it's hard to make the adjustment properly but this is gist of it:
showNewWindow: function(menu) {
var me = this,
newWindowId = sports.util.Utils.randomString(12);
//
// Make a synchronous request so that the new window will
// not load as a popup.
//
debugger;
var popup = sports.util.Utils.openNewWindow('', 'menu', {}, null, null, newWindowId);
Ext.Ajax.request({
async: false,
url: sports.util.Utils.getContextPath() + '/tabClicks.do',
params: {
oldWindowId: sports.util.Utils.getWindowName(),
newWindowId: newWindowId
},
success: function() {
popup.location.href = "/desktop/main";
},
scope: me
});
},
Popup blockers try to tell when a window is being opened in direct response to a user action or spontaneously by the application. The way they probably do this is by checking whether the function that called window.open() was run in response to a user-triggered event like a mouse click.
When you perform a synchronous AJAX request, the function that was triggered by the mouse click is still running when the response arrives and the success function calls window.open. So it's considered to be a user-requested window, not a popup.
When you use asynchronous AJAX, the click handler is no longer running when the success function runs. The asynchronous call to window.open is considered spontaneous by the browser, so it blocks it.
I don't think there's any way around this, because anything you could do could also be used by everyone else to get around popup blockers, and they would be useless.