Link to home
Start Free TrialLog in
Avatar of Loganathan Natarajan
Loganathan NatarajanFlag for India

asked on

How do I close the pop up?

I am using this to create model windows, http://prototype-window.xilinus.com/samples.html

After the pop up window, when I click the outside section, Is it possible to close the pop up window instead of click the close button or icon right corner?

Avatar of brad2575
brad2575
Flag of United States of America image

IF the code is on the popup itself you can just use

window.close()

note:  Some browsers still have a popup asking if you want to close the window.
Avatar of Loganathan Natarajan

ASKER

Hi,

Will this work on the out side click? how it will be invoked?

I want the pop up to be closed automatically when I click the outside area
You create a window by creating an instance of the Window object and pass some properties along.

var win = new Window({className: "dialog", width:350, height:400, zIndex: 100, resizable: true, title: "Sample window", showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff, draggable:true, wiredDrag: true})

To display it you probably use : win.showCenter() or win.show()
To close the window just use : win.close()
brad: It is not a window object

I believe Albert is correct
Use onblur and window.close

<html>
<head>
<script type="text/javascript">
function upperCase()
{
var x=document.getElementById("fname").value;
document.getElementById("fname").value=x.toUpperCase();
}
</script>
</head>
<body onblur="window.close();">
 
<h1>Hello World</h1>
 
</body>
</html>

Open in new window

I placed an extra function in the example above.

Below is a simple implementation.
<html>
<head><title>Title</title>
</head>
<body onblur="window.close();">
<h1>Hello World</h1>
</body>
</html>

Open in new window

Hank: it is not a window object!!!
Try to implement an observer and handle the onblur event.
See the documentation : http://prototype-window.xilinus.com/documentation.html
// Create and open the window
var win = new Window({className: "dialog", width:350, height:400, zIndex: 100, resizable: true, title: "Sample window", showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff, draggable:true, wiredDrag: true});
win.show();
 
myObserver = {
	onBlur: function(eventName, win) {
		win.close();
		Windows.removeObserver(this);
	}
}
 
Windows.addObserver(myObserver)

Open in new window

Thanks to all!

@AlbertVanHalen ...

Where should I put this code?

That new window code is being in the include JS file it is OK.. now I want to execute the below code where?



myObserver = {
        onBlur: function(eventName, win) {
                win.close();
                Windows.removeObserver(this);
        }
}
 
Windows.addObserver(myObserver)

Open in new window

Hi guys,

This is the code followed on the Close ICON of the dialog windows....

<input type='image' src='images/close.jpg' title='fermer' onclick='Dialog.okCallback()' " + okButtonClass + "/>\

Is it possible to call this function "onclick='Dialog.okCallback()" out side of the pop up (i.e main window) so that it will close automatically??
This is the code in okCallback();

okCallback: function()
{
	  
    var win = Windows.focusedWindow;
 	//alert("Hello"+win);
    if (!win.okCallback || win.okCallback(win)) 
   {
      // Remove onclick on button
      $$("#" + win.getId()+" input").each(function(element) {element.onclick=null;})
      win.close();
    }
}

Open in new window

Incase If I call the above code on the onblur body tag... i get the null error on this line?

Looks like that line is empty

var win = Windows.focusedWindow;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Albert Van Halen
Albert Van Halen
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@AlbertVanHalen: .. You are right. I have put this.. I get error in IE ... but no error in FF
Can you post some code or give a link to your site so I can investigate further?