有一种方法可以将滚动条从 iframe 对齐到右侧吗?默认为左。
任何的想法?
看看这里我想在加载页面时看到搜索框!
我有一个具有 ifram 的应用程序,在 ifram 中我正在加载一个搜索框位于右上角的网站,
我希望当页面加载时我应该能够立即看到搜索框而不必向右滚动....有什么不清楚的地方吗?
你能用jquery吗?如果是,您可以执行以下操作:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<p>This is some text. This is some text. This is some text.
<div id="frame" style="width: 200px; height: 200px; overflow: scroll";>
<iframe src="http://www.w3schools.com/default.asp" width="1024" height="768" scrolling="no">
<p>Your browser does not support iframes.</p>
</iframe>
</div>
This is some text. This is some text. This is some text.</p>
<p>The align attribute was deprecated in HTML 4, and is not supported in HTML 4.01 Strict DTD or in XHTML 1.0 Strict DTD. Use CSS instead.</p>
<script type="text/javascript">
jQuery(document).ready(function () {
$("#frame").scrollTop(10).scrollLeft(750);
});
</script>
</body>
</html>
如果您将代码复制并粘贴到 html 文件中并在浏览器中打开它,您会看到 iframe 自动滚动到最右侧。
主要变化是:
<div>
, be sure to specify the width & height (less than the iframe width & height)add the javascript code before the closing </body>
tag
<script type="text/javascript">
jQuery(document).ready(function () {
$("#frame").scrollTop(10).scrollLeft(800);
});
</script>