How to scroll automatically to the center in iframe within a handler?
I have t开发者_StackOverflow社区his code
<a href="index.php?option=com_surveys&Itemid=120&act=view_survey&survey=1:basic-survey" class="modal" rel="{handler: 'iframe', size: {x: 680, y: 500}}">Click here</a>
and i need to use this code, no way around it. i have gone crazy looking for a way to make THIS CODE scroll the iframe to the middle of the page. please help. I never used an iframe within a handler and using the modal class like that, i don't know where the parameters will go, or even what parameter will go. i tried a few with no success.
thanks
You're question is unclear....do you need to scroll to a point on the page with the click of a button? If so use to scrollWindow/scrollTo function, e.g.:
<html>
<head>
<script type="text/javascript">
function scrollWindow()
{
window.scrollTo(100,500);
}
</script>
</head>
<body>
<input type="button" onclick="scrollWindow()" value="Scroll" />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
</body>
</html>
If you want to align the iframe to the centre, use a table, e.g.:
<body>
<table width="100%" height="100%">
<tr align="center">
<td align="30px">
<div id="iframe" style="position:relative;overflow:hidden;width:100%; height:100%;">
Insert iframe code here</div>
</td>
</tr>
</table>
</body>
精彩评论