473,770 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.frame0 1.scroll(x,y)

or possibly

document.getEle mentById('frame 01').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 3171
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.frame0 1.scroll(x,y)
This is a proprietary short-hand notation that you want to avoid.
or possibly

document.getEle mentById('frame 01').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 HTMLIFrameEleme nt 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 `contentDocumen t'
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.getEle mentById("...") ;
o.contentDocume nt.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.getEle mentById("...") ;
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 bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
Jun 27 '08 #2

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

Similar topics

2
1810
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 code provided on the website. Once I have this example running correctly, I will need to use the concept in a more complex project. The code I am using involves an webform and an htc file. The code for ScrollPos.htc (which is located in a folder...
1
5179
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: window.scrollTo(x,y)
2
9055
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 object (both the HTML and control are built in the same .ascx file) The target button simply fires an event in the WebUserControl-derived object. So, alternatively, if there was a mechanism to call a method (explicitly or using an event of some...
6
9391
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 can use it there. Thanks in advance :) Paul
2
9791
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 the treeview is collapsed and the node isn't selected. Expanding and selecting the node via code in the load event works, but how do I achieve, that the treeview scrolls down to the selected node? Thanks for any help Claus
2
4347
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 links to pages inside the mother page. The purpose is to show changes since last login. If you click on one link inside it takes you to the changes. If there are a lot of changes you might need to use the internal vertical scroll bar inside the...
1
3577
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, its another!!) The page is basic - a generic, blank page with navigation a picture presentation area, and a frame showing different thumbnails. Problem: Once the user has scrolled down the frame and selected a picture, the frame resets to...
2
3281
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 quicktime or windows meida player depending on which plugin was found. after the plug in is found a iframe with the right player is created. here is the code. for some reason In IE the plug in doesnt work and in fire fox it crashes <!DOCTYPE html...
3
2600
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.. http://www.integrityads.net/fashions/collection.htm Also it is not resolution compatible,i.e. alignment totally messed up when i increased the resolution.Please suggest. Code is as follows:- <HTML><HEAD> <meta http-equiv="Content-Language" content="en-us"> <TITLE>Collections</TITLE>...
0
10230
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10004
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7416
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.