I was developing a struts web application, in one of my JSP I created a button to open a new window. The way I did it is:
window.open(location,'_blank');
everything works fine except the new window is always scrolled down to the bottom itself. How to show the top part instead?
I am using Chrome.
Include place this JS at the bottom of the page just before the closing body tag.
<script>window.scrollTo(0,0);</script>
Or you could simply use jQuery if your page is already including it:
<script>$(document).ready(function(){$(window).scrollTop(0);});</script>
Try something like this:
var newWindow = window.open(someUrl, '_blank');
newWindow.onload = function(){
newWindow.scrollTo(0, 0);
}
newWindow.onload();
尝试这个
window.open(location,'_blank','top=50');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.