Javascript-在弹出窗口中滚动至底部 [英] Javascript - Scroll to bottom on a pop-up window
本文介绍了Javascript-在弹出窗口中滚动至底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<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.
当用户单击网页上的CLICK HERE
时,将出现一个弹出窗口,它将您定向到http://www.google.ca
网页.我的问题是如何做到这一点,以便在单击CLICK HERE
时弹出窗口会自动滚动到页面底部?
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?
我找到了以下代码段:
window.scrollBy(0,50)
,但是它将网站本身滚动到底部.它不会滚动弹出窗口.
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.
推荐答案
尝试使用这样的onload
事件
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);
};
}
这篇关于Javascript-在弹出窗口中滚动至底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文