Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can popup a window in a new URL but also shadow out the current window and prevent clicks (possibly with jQuery)

I am normally used to "window.open" to open a popup window into a new URL. How can open a window into a new URL, shadow out/grey out the current window, and on close remove the shadow background.

Is it best to use jQuery to do this? Could I use the default libraries without use jquery plugins?

I want to do something like this and then "disable" my shadow on unload. Hopefully that uses core jQuery libraries or standard javascript calls. I want to avoid using any plugins besides jQuery.

var popup = window.open('http://google.com', 'popup');
showShadow();
$(window).unload(function() {
    if(!popup.closed) {
        disableShadow();
    }
});
like image 679
Berlin Brown Avatar asked Dec 05 '22 14:12

Berlin Brown


1 Answers

Basically, you can open the popup and set that window the beforeunload. In short, something like this:

popup = window.open("", "name", "width=400, height=300")
popup.onbeforeunload = function() { $('#shadow').hide();}

I created a fiddle for you.

http://jsfiddle.net/DDksS/

like image 82
Bart Calixto Avatar answered Dec 28 '22 10:12

Bart Calixto