Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#9606 closed defect (fixed)

Menu: bugs when attaching menu to an iframe

Reported by: Douglas Hays Owned by: bill
Priority: high Milestone: 1.4
Component: Dijit Version: 1.3.2
Keywords: Cc:
Blocked By: Blocking:


Run the attached menubug.html file.
You get an error: dijit.Menu._iframeContentDocument is not a function
This comes from Menu.js. Seemingly, this._iframeContentDocument should have been used.
I changed the 2 occurances in Menu.js and the exception goes away.
Then I scroll the iframe to the bottom and right click.
The context menu appears far below the mouse pointer.
This seems to be because the iframe scrolling was ignored.
I added this to _openMyself and that seems to have fixed that:

var scroll = dojo.withDoc(, "_docScroll", dojo);
y -= scroll.y;
x -= scroll.x;

I also noticed this line in bindDomNode that appears to be unneeded code:

var win = dijit.getDocumentWindow(node.ownerDocument);

Attachments (2)

menubug.html (952 bytes) - added by Douglas Hays 12 years ago.
9606.patch (1.4 KB) - added by Douglas Hays 12 years ago.
proposed changes

Download all attachments as: .zip

Change History (12)

Changed 12 years ago by Douglas Hays

Attachment: menubug.html added


Changed 12 years ago by Douglas Hays

Attachment: 9606.patch added

proposed changes

comment:1 Changed 12 years ago by bill

Milestone: tbd1.4
Status: newassigned

Definitely an improvement. That <iframe> code in Menu isn't well tested because although menu was designed to work on an <iframe> so that Editor could use it, Editor isn't actually using it.

The patch as is though messes up menus menus on a main document when the main document is scrolled (try scrolling down test_Menu.html, at least on FF3.5/mac where I tested).

comment:2 Changed 12 years ago by bill

I checked in your changes to fix the exception as [19091].

comment:3 Changed 12 years ago by bill

Resolution: fixed
Status: assignedclosed

(In [19093]) Changes to adjust coordinates for mouse click occurring on an <iframe>. Since Menu actually connecst to the <iframe>'s <body> node, the event.pageX and pageY are relative to the <iframe>, but we need them to be relative to the main document, where dojo is running.

Working everywhere (safari, FF, and IE) except for FF2 which shows the browser menu in addition to the dijit.Menu.

Fixes #9606 !strict.

comment:4 Changed 12 years ago by bill

Summary: Menu: bugs when using iframesMenu: bugs when attaching menu to an iframe

comment:5 Changed 12 years ago by bill

(In [19095]) Revise formula for calculating pageX/pageY in the main document based on event object from the <iframe>'s <body> node. Refs #9606 !strict.

comment:6 Changed 12 years ago by bill

Resolution: fixed
Status: closedreopened

Still some open issues here:

  • On FF and safari when the browser window itself is scrolled, the menu appears too high. I think this is caused by a general problem with dojo.coords(iframe), w/o the second parameter set to true.
  • IE's menu placement is a little off. Perhaps the code shouldn't be including the iframe's border or padding into the calculation.
  • If the iframe's content is changed (ie, src parameter is changed) or if the Menu is connected to the iframe before it finishes loading, then we lose the connection. That's because the Menu code is actually connecting to the <body> node inside of the iframe.

comment:7 Changed 12 years ago by bill

(In [19105]) Menu on iframe related fixes (refs #9606 !strict):

  1. Fix from Doug so that scrolling main document doesn't mess up menu position
  2. Rebind any time the iframe contents are reloaded (ie, any time the iframe src is changed). This is needed since a connection to an iframe is actually connecting the <body> node inside the iframe. (note: had to work-around broken dojo.connect(iframe, "onload), refs #9609).

comment:8 Changed 12 years ago by bill

Resolution: fixed
Status: reopenedclosed

(In [19106]) Fix menu placement for menus on iframes on IE, fixes #9606 !strict.

comment:9 Changed 12 years ago by bill

(In [19522]) Fix placement problems for menu on iframe when iframe is in a div w/position:relative (or position:absolute), and convert code to use dojo.position() rather than dojo.coords(). Refs #9606, #9648 !strict.

comment:10 Changed 11 years ago by bill

(In [20980]) Fix menu positioning and remove a bunch of unneeded code (cut & pasted function from Menu.js which is no longer necessary). Refs #9606, fixes #10472 !strict.

Note: See TracTickets for help on using tickets.