Log in

View Full Version : iFrames



Script Kiddie
01-28-2007, 12:00 PM
Is it possible to:


Make an iFrame only show a certain part of an external webpage?
Make the iFrame scroll to a certain pixel distance on that external webpage when your webpage is loaded?


I am told that there are certain ways to do option 2, but no-one has given me codes for that yet.

I assume it would be a simple add-on to a tag, for example:


<iFrame src="http://www.target.com/" width="100" height="100" scrollTo="183,32">

The red part is something I made up and have tried (it doesn't work unfortunately :( ), but hopefully you guys will know something that does work. Thanks for your time.

mburt
01-28-2007, 12:33 PM
scrollTo isn't a valid iFrame property, but it probably is possible to do this with JavaScript. Try googling your query :)

Script Kiddie
01-28-2007, 05:44 PM
scrollTo isn't a valid iFrame propertyYes, I do know this. Haven't you read what it says below the code?

mburt
01-28-2007, 05:51 PM
The onscroll property doesn't work for the iframe tag either. I can't see how it's possible, unless you change the page you are displaying.

mburt
01-28-2007, 05:53 PM
This is how it would work with a DIV:


<html>
<head>
<script type="text/javascript">
function test() {
var frame = document.getElementById("test")
window.status = frame.scrollTop
if (frame.scrollTop > 183) {
frame.scrollTop = 183
return false;
}
}
</script>
</head>
<body>
<div style="height:200px;width:500px;overflow-y:scroll" id="test" onscroll="test()">
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
<br>test
</div>
</body>
</html>