简体   繁体   中英

Need a little help with this iframe scrolling issue

I'm attempting to do some scrolling with an iframe, but my Javascript doesn't seem to be working.

Here's my code...

<html>
<head>
<script type="text/javascript">
    function loadorder() {
    theFrame = document.getElementsByName("iframename");

    if (theFrame <> null) {
       theFrame.src="";
       theFrame.contentWindow.scrollTo(528,65)
    }
    else {
        alert("could not get iframe element!");
    }
}
</script>
</head>
<body>
    <iframe name="iframename" src="http://www.domain.com/otherpage.html" frameborder="0"></iframe>
</body>
</html>

I got this code from another site and have modified it a little to fit my needs.

Basically what I'm trying to do is show a banner from another HTML page in the iframe on this page.

It's all on the same domain though, so I'm not really sure why this isn't working...

Like Ktash said the SQL not equal won't work in javascript:

if (theFrame <> null) 

However, with javascript null and undefined equates to false. So you can do this:

// if theFrame exists...
if (theFrame) {
   theFrame.src="";
   theFrame.contentWindow.scrollTo(528,65)
}
else {
    alert("could not get iframe element!");
}

Your <> is not a valid operator. I think you mean != .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM