0
<script type="text/javascript">
// Popup window code
function newPopup(url) {
    popupWindow = window.open(url,'popUpWindow','height=500, width=800, left=10, top=10, resizable=yes, scrollbars=yes, toolbar=yes, menubar=no, location=no, directories=no, status=yes')
}
</script>


<a href="JavaScript:newPopup('http://www.google.ca');">CLICK HERE</a></a> to go to google.

When the user click on CLICK HERE on the webpage, a pop-up window will appear and it directs you to the http://www.google.ca web page. My question is how do I make it so that the pop-up window will automatically scroll to the bottom on the page when CLICK HERE is clicked?

I found this code segment: window.scrollBy(0,50), but it scrolls the website itself to the bottom. It doesn't scroll the popup window.

J0nathan Lam
  • 141
  • 1
  • 3
  • 10

3 Answers3

1

Try use onload event like this

function newPopup(url) {
    popupWindow = window.open(url,'popUpWindow','height=500, width=800, left=10, top=10, resizable=yes, scrollbars=yes, toolbar=yes, menubar=no, location=no, directories=no, status=yes');
    popupWindow.onload = function () {
        popupWindow.scrollTo(0, popupWindow.document.body.scrollHeight);
    };
}
icaru12
  • 1,522
  • 16
  • 21
0

You could try creating an anchor?

<a name="whereYouWantToScrollTo">Click To Scroll To Top</A> 

http://www.webmastercourse.com/articles/anchors/ I'm not sure if you can activate an anchor with JavaScript, but that's the only way I know how to force the user to scroll down on a webpage. Hope this helps

Ian Wise
  • 706
  • 2
  • 10
  • 31
0

if your popup has an id you can use this code to get at the top of that popUp.

$("#confirma_modificacion_documento").animate({ scrollTop: 0 }, "fast");

when your popUp is:

<div class="modal fade" id="confirma_modificacion_documento" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"