Link to home
Create AccountLog in
Avatar of Loganathan Natarajan
Loganathan NatarajanFlag for India

asked on

How do I resolve the pop up close issue?

Please ref. https://www.experts-exchange.com/questions/24211970/How-do-I-close-the-pop-up.html

I have been tried to put the "Dialog.okCallback();" on the body tag like this,

<body onclick="Dialog.okCallback();" bgcolor="#333333">

It works in FF, not in IE... How do I resolve this.

I have attached the complete (simple script)... Please look at it.

Download the source, http://boscoits.com/popwindow.zip
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

try




<html>
<head>
<script type="text/javascript">
window.onload=function() {
  if (document.body && document.body.attachEvent) {
    document.body.attachEvent('onclick',function() {Dialog.okCallback()});
  }
  else document.body.onclick=function() { Dialog.okCallback() }
}
</script>
</head>
<body>
.
.

Open in new window

Avatar of Loganathan Natarajan

ASKER

I tried like this,

the same error persists,

<html>
<head>
<title>Test</title>
 
<link href="themes/default.css" rel="stylesheet" type="text/css" ></link> 
<link href="themes/alphacube.css" rel="stylesheet" type="text/css" ></link>
 
<script type="text/javascript" src="javascripts/prototype.js"></script>
<script type="text/javascript" src="javascripts/effects.js"></script>
<script type="text/javascript" src="javascripts/application.js"></script>  	
<script type="text/javascript" src="javascripts/window.js"></script>
 
<script type="text/javascript">
window.onload=function() {
  if (document.body && document.body.attachEvent) {
    document.body.attachEvent('onclick',function() {Dialog.okCallback()});
  }
  else document.body.onclick=function() { Dialog.okCallback() }
}
</script>
 
 
<script type="text/javascript">
	var win = null;
	var index = 1;
 
	function openDialog(id,popupbg,pwidth) 
	{
	  //alert("Hello "+pwidth);
	  Dialog.alert($(id).innerHTML, {className: "alphacube",  width: pwidth, id: "d" + index, popupbg: popupbg})
	  index++;
	}
	
	function lastDialog(id) 
	{
	  Dialog.confirm($(id).innerHTML, {className: "alphacube",  width:250, okLabel: "Close All", ok: closeAllModalWindows})
	}
	
	function closeAllModalWindows() 
	{
		Windows.closeAllModalWindows();
		return true;
	}
	function okCallback() {
       win.close();
    }
  }
</script>
 
 
</head>
<body bgcolor="#333333">
<div>
	<script>Application.addInfo(' ', 'info')</script>
	<div style="display:none"> 
		<xmp id="info">
			Dialog.alert({url: "info.htm", options: {method: 'get'}}, 
			{
				className: "alphacube",
				width:400, 
				okLabel: "Close"
			}
			);
		</xmp>
	</div>	
</div>
</body>
</html>

Open in new window

I am getting this on the screen.

ERR2.JPG
Where is
new Dialog instantiated?
It is there in window.js


    var win = new Window(parameters);
    win.getContent().innerHTML = content;
    
    win.showCenter(true, parameters.top, parameters.left);  
    win.setDestroyOnClose();
    
    win.cancelCallback = parameters.onCancel || parameters.cancel; 
    win.okCallback = parameters.onOk || parameters.ok;
    
    return win;    
  },

Open in new window

everything is there in the .js file?

Can you see it from the attachment please?
Sorry I did not see the zip in the question
You have a curly bracket too many

<script type="text/javascript">
	var win = null;
	var index = 1;
 
	function openDialog(id,popupbg,pwidth) 
	{
	  //alert("Hello "+pwidth);
	  Dialog.alert($(id).innerHTML, {className: "alphacube",  width: pwidth, id: "d" + index, popupbg: popupbg})
	  index++;
	}
	
	function lastDialog(id) 
	{
	  Dialog.confirm($(id).innerHTML, {className: "alphacube",  width:250, okLabel: "Close All", ok: closeAllModalWindows})
	}
	
	function closeAllModalWindows() 
	{
		Windows.closeAllModalWindows();
		return true;
	}
	function okCallback() {
       win.close();
    }
  } <<<<<<<<<< remove

Open in new window

I get

Error: win is null
Source File: window.js
Line: 1569

which is

okCallback: function() {
    var win = Windows.focusedWindow;

I have removed the extra " }  "  ... OK, syntax error is fixed...

but my original error remains the same... after the pop up window open, if I click the out side ... there is error ...

see the attachment...

so i too face the same error on line number 1569 in window.js file

ERR3.JPG
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
That worked it. Thank  you sir. really you are so great!!!

I never thought to handle the null in my programming experience on the javascript...
Fantastic Answers. Thanks so much!
It does leave the qestion WHY there is no focussed window set in the code