如何让竖向滚动条位置保持不变
怎么让竖向滚动条位置保持不变
js代码和css样式:
<script type="text/javascript">
var BigImgUrl;
function BackFullScreen(BigImgUrl) {
var scrollTop = document.body.scrollTop;
var FullScreenDiv = document.getElementById("FullScreenDiv");
FullScreenDiv.style.width = document.body.clientWidth + "px";
FullScreenDiv.style.height = document.body.clientHeight + "px";
FullScreenDiv.style.display = "block";
var ShowBigImgDiv = document.getElementById("ShowBigImgDiv");
var ShowBigImgDivPosition;
ShowBigImgDiv.style.display = "block";
ShowBigImgDiv.innerHTML = "<img src=\"" + BigImgUrl + "\" width=\"800\" height=\"600\" border=\"0\" />";
ShowBigImgDivPosition = document.documentElement.scrollTop;
if (ShowBigImgDivPosition == 0 || ShowBigImgDivPosition == "") {
ShowBigImgDivPosition = document.body.scrollTop;
}
ShowBigImgDiv.style.top = ShowBigImgDivPosition + ((window.screen.height - ShowBigImgDiv.clientHeight) / 2 - 170) + "px";
ShowBigImgDiv.style.left = (window.screen.width - ShowBigImgDiv.clientWidth) / 2 - 90 + "px";
}
function BackFullScreenHidde() {
document.getElementById("ShowBigImgDiv").style.display = "none";
document.getElementById("FullScreenDiv").style.display = "none";
}
</script>
<style type="text/css">
#ShowBigImgDiv
{
position: absolute;
z-index: 10001;
display: none;
cursor: pointer;
}
#FullScreenDiv
{
position: absolute;
z-index: 10000;
display: none;
background-color: #FFFFFF;
filter: alpha(opacity=50);
opacity: 0.5;
cursor: pointer;
}
</style>
html:点击图片显示大图后,滚动条被置顶了,请教要使滚动条位置保持不变 应该怎么解决?
<td class="img_pic" style="width: 180px; height: 150px;">
<div id="ShowBigImgDiv" onclick="BackFullScreenHidde()" title="点击缩小"></div>
<div id="FullScreenDiv" onclick="BackFullScreenHidde()" title="点击缩小"></div>
<a href="#"><img src="$imgpath/shop_business.jpg" width="150" height="116" onclick="BackFullScreen(this.src)"/></a>
<p>1、图片样板</p>
</td>
------解决方案--------------------
js代码和css样式:
<script type="text/javascript">
var BigImgUrl;
function BackFullScreen(BigImgUrl) {
var scrollTop = document.body.scrollTop;
var FullScreenDiv = document.getElementById("FullScreenDiv");
FullScreenDiv.style.width = document.body.clientWidth + "px";
FullScreenDiv.style.height = document.body.clientHeight + "px";
FullScreenDiv.style.display = "block";
var ShowBigImgDiv = document.getElementById("ShowBigImgDiv");
var ShowBigImgDivPosition;
ShowBigImgDiv.style.display = "block";
ShowBigImgDiv.innerHTML = "<img src=\"" + BigImgUrl + "\" width=\"800\" height=\"600\" border=\"0\" />";
ShowBigImgDivPosition = document.documentElement.scrollTop;
if (ShowBigImgDivPosition == 0 || ShowBigImgDivPosition == "") {
ShowBigImgDivPosition = document.body.scrollTop;
}
ShowBigImgDiv.style.top = ShowBigImgDivPosition + ((window.screen.height - ShowBigImgDiv.clientHeight) / 2 - 170) + "px";
ShowBigImgDiv.style.left = (window.screen.width - ShowBigImgDiv.clientWidth) / 2 - 90 + "px";
}
function BackFullScreenHidde() {
document.getElementById("ShowBigImgDiv").style.display = "none";
document.getElementById("FullScreenDiv").style.display = "none";
}
</script>
<style type="text/css">
#ShowBigImgDiv
{
position: absolute;
z-index: 10001;
display: none;
cursor: pointer;
}
#FullScreenDiv
{
position: absolute;
z-index: 10000;
display: none;
background-color: #FFFFFF;
filter: alpha(opacity=50);
opacity: 0.5;
cursor: pointer;
}
</style>
html:点击图片显示大图后,滚动条被置顶了,请教要使滚动条位置保持不变 应该怎么解决?
<td class="img_pic" style="width: 180px; height: 150px;">
<div id="ShowBigImgDiv" onclick="BackFullScreenHidde()" title="点击缩小"></div>
<div id="FullScreenDiv" onclick="BackFullScreenHidde()" title="点击缩小"></div>
<a href="#"><img src="$imgpath/shop_business.jpg" width="150" height="116" onclick="BackFullScreen(this.src)"/></a>
<p>1、图片样板</p>
</td>
------解决方案--------------------