473,240 Members | 1,632 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,240 software developers and data experts.

Invoking scroll method for an IFRAME object in HTML javascript

How do I invoke the scroll() method of a window object for a
scrollable IFRAME element in an HTML document?

I am using IE 7.0, and I thought the following would work:

document.frame01.scroll(x,y)

or possibly

document.getElementById('frame01').scroll(x,y)
where the javascript is embedded within an HTML document containing
the following:

<IFRAME id="frame01" src="http://wrch.com/pages/1466587.php"
scrolling="yes" style="HEIGHT : 250px; WIDTH : 300px">
No support for IFRAME tag.
</IFRAME>

Thanks in advance for any help you may be able to provide.
John L.
Jun 27 '08 #1
1 3105
John L. wrote:
How do I invoke the scroll() method of a window object for a
scrollable IFRAME element in an HTML document?

I am using IE 7.0, and I thought the following would work:

document.frame01.scroll(x,y)
This is a proprietary short-hand notation that you want to avoid.
or possibly

document.getElementById('frame01').scroll(x,y)

where the javascript is embedded within an HTML document containing
the following:

<IFRAME id="frame01" src="http://wrch.com/pages/1466587.php"
scrolling="yes" style="HEIGHT : 250px; WIDTH : 300px">
No support for IFRAME tag.
The content of the `iframe' element (and other multimedia-related elements)
should provide an *alternative* for users where that feature is not
available (you see, HTML provides *built-in* means for graceful
degradation). To state merely that the feature does not work (in *wrong*
terms[1] that Joe User also is not likely to understand at all) ignores that
recommendation for no good reason. Please fix that; a hyperlink to the
frame resource, with a descriptive text content, would suffice here.

[1] There is no IFRAME tag; there is an IFRAME/iframe _element_, and there
are an <iframe ...start tag and an </iframeend tag for this element.
See also the HTML 4.01 Specification, section 3.2.1 (esp. the last
paragraph.)
</IFRAME>
Your script code cannot work because both lines would refer to the element
object implementing the HTMLIFrameElement interface (or its proprietary
counterpart; heretoafter: "the IFrame object"), not the object implementing
the Window interface (same as before; heretoafter: "the Window object").
I know of no DOM where *this object* would have a `scroll' method.

Generally, there are three ways to refer to the corresponding Window object.
All of which have been mentioned several times before here (IIRC); please do
a little research before you post next time.

A) The standards-compliant one

Per W3C DOM Level 2 HTML, the IFrame object has a `contentDocument'
property to refer to the (HTML)Document object of the view created by
the `iframe' element. Per W3C DOM Level 2 Views, the latter object
has a `defaultView' property to refer to an object implementing the
AbstractView interface which AFAIK is identical with the corresponding
Window object:

var o = document.getElementById("...");
o.contentDocument.defaultView

B) The almost standards-compliant one

Per proprietary DOMs (e.g. Gecko DOM and MSHTML DOM), the IFrame object
also has a `contentWindow' property to refer to its inner Window object
directly:

var o = document.getElementById("...");
o.contentWindow

C) The fully proprietary one

Per the (still proprietary) quasi-standard of "DOM Level 0" for
client-side scripting of HTML user agents, the object referred to
by the host-defined `window' property of the Global Object has a
`frames' property that is a collection of references to the Window
objects created by `frame' and `iframe' elements in the HTML document.

Therefore, either the `iframe' element needs to be given a name (maybe
instead of an ID), or it can only be referred to by its zero-based index
within that collection:

window.frames[...]
Approach C is, for historical reasons, currently the most compatible one, so
it can serve as a general fallback. (But, at least in the Gecko/20080404
DOM, if the element is included dynamically, the element object's `name'
property has to be set before it is appended as child node object.)

You should also feature-test the proprietary `scroll' method at runtime
before you call it.
HTH

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: GrantS | last post by:
I am trying to convert the VB.Net code example povided by http://authors.aspalliance.com/JimRoss/Articles/MaintainScrollPos.aspx into C# (ASP.Net)without success. No errors are thrown in the VB...
1
by: Alexander | last post by:
Scroll IFrame Content to desired Position (JavaScript) ====================================== How can I scoll the content of an Ifram to a desire Position? The function should be:...
2
by: JCE | last post by:
I need to programmatically invoke an asp:Button click event from a javascript function. The page containing the script and the button is the HTML page associated with a WebUserControl-derived...
6
by: paul | last post by:
HI! How do we send a variable from an Iframe page back to its parent? I have a script that calculates the iframe's window size but I need to know how to send that value back to its parent so I...
2
by: Claus | last post by:
Hello, I have a long treeview with scrollbars. When I scroll down and press a treeview node, then the Load event fires and navigate in an iframe to another page. The problem is, that afterwards...
2
by: Merlin | last post by:
Hi there, I do have a complex problem and wonder if this is possible to solve. Following situation. I do have a page, where you do have a frame inside that page. That frame holds different...
1
by: bulldog8 | last post by:
I am working on a picture preview page ... some questions and suggestions have been incorporated already, but the 'user' (i.e. wife!) would like it to be more user friendly (if it isn't one thing,...
2
riptide2049
by: riptide2049 | last post by:
I really have a problem here. I have a code that is suppost to take the href of a link from the right class;value of a link maked toreturn false. the value is a Media file the file is sent to...
3
by: PrabodhanP | last post by:
I have CSS based mouseover scrolling for divContent embeded in my webpage.It works fine in IE,but not working in mozilla-FF. It is located at the location.....
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.