After close(),the scrollbar of main window scrolls back

hello, I create a dhtmlxwindow with clicking a button in main window, the created window attaches to an url page of the same domain,when after operating in window, I want the main window’s vertical scrollbar scrolls to bottom, here are part of the code:

parent.window.scrollToBottom(); //alert("close");// here ,pay attention~ parent.closeExistSchema(); //=================== function closeExistSchema(){ dhxWins.window("existSchema").close(); } function scrollToBottom(){ window.scrollTo(0,document.body.scrollHeight); }

the only problem is that the vertical scrollbar doesn’t scroll to the bottom, if I uncomment this sentence: alert(“close”), the main window scroll bar does scroll to the bottom, then click “ok” of alert window, then the scroll bar goes up to its original place, so why? why the bar goes back?
regards,

Hello,

Try to call scrollToBottom after close() of dhx window :

parent.closeExistSchema();
parent.window.scrollToBottom();

also you may try to call scrolling with 1ms timeout:

window.setTimeout(function(){
parent.window.scrollToBottom();
},1);
parent.closeExistSchema();

hi,
if I call scrollToBottom() after close(),an error arises:

alert(parent.window.location.href);//main window  url
parent.closeExistSchema();
alert(parent.window.location.href);//created window url
parent.window.scrollToBottom();

after close the window,the parent.window is not the main window but the created one,so there is no scrollToBottom() in created window, why “parent.window.location.href” are not same in two times?

and your second solution:

            window.setTimeout(function(){
	    alert(parent.window.location.href);();//created window url
	    parent.window.scrollToBottom();
 	},1);
	parent.closeExistSchema();

here parent.window.location also points to the created window, why ?
I can post my full code if it is needed.
thanks.

hi, I write a demo,there are two pages:test1.jsp and test2.jsp,and click a button in test2.jsp to open test1.jsp in a dhtmlXwindow, then click a button in test1.jsp to close the dhtmlXwindow and then make scrollbar in test2.jsp to scroll to the bottom. here are my code:
test1.jsp:

<script type="text/javascript">
	function closeSelf(){
		//solution1 =====
		/*
		alert(parent.window.location.href);//test2.jsp, 
		parent.closeMe();
		alert(parent.window.location.href);//test1.jsp,
		parent.scrollToBottom();//no scrollToBottom() in test1.jsp
		*/
		//solution2 =======
		window.setTimeout(function(){
			alert(parent.window.location.href);//test1.jsp
			parent.window.scrollToBottom();//no scrollToBottom() in test1.jsp
		},1);
		parent.closeMe();
	}
</script>

<body>
	Hello, this is my included test1.jsp page
	<br/>
	<input type="button" value="closeMe" onclick="closeSelf()"/>
</body>

test2.jsp:

<script type="text/javascript" src="../js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="../js/dhtmlxwindow/dhtmlxcommon.js"></script>
<script type="text/javascript" src="../js/dhtmlxwindow/dhtmlxcontainer.js"></script>
<script type="text/javascript" src="../js/dhtmlxwindow/dhtmlxwindows.js"></script>
<link rel="stylesheet" type="text/css" href="../css/dhtmlxwindow/dhtmlxwindows.css"/>
<link rel="stylesheet" type="text/css" href="../css/dhtmlxwindow/skins/dhtmlxwindows_dhx_skyblue.css"/>
<script type="text/javascript" src="test.js"></script>
<input type="button" value="openMe" onclick="openMe()"/>
	<br/><br/>
	This page is the main page<br/>
	fill in content to make vertical scrollBar appear<br/>
	fill in content to make vertical scrollBar appear<br/>
             ......

test.js:

var dhxWins = null;
function openMe(){
	dhxWins = new dhtmlXWindows();
	dhxWins.enableAutoViewport(true);
	dhxWins.setImagePath("../css/dhtmlxwindow/imgs/");
	var me = dhxWins.createWindow("me",0,0,500,400);
	me.setText("Test");
	me.attachURL("test1.jsp");
	me.button("minmax1").disable();
	//me.centerOnScreen();
}
function closeMe(){
	dhxWins.window("me").close();
}
function scrollToBottom(){
	window.scrollTo(0,document.body.scrollHeight);
}

in closeSelf() of test1.jsp, the two solutions don’t work well neither, so what can to be done to my question ?
regards,

sorry, I forget to say , these code can be runned in html pages, not limited to be in jsp

Try to use the following approach to scroll the page to the bottom:

w1.attachEvent(“onClose”,function(){
window.setTimeout(function(){
window.scrollTo(0,document.body.scrollHeight);
},1)
return true
});

This event handler should be set in the test2.jsp.

I have attached the sample
sample.zip (33.1 KB)

ok, it works.
thanks very much!