473,546 Members | 2,644 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

iframe height problem & oncontextmenu event never triggered

Hi there,

I have an iframe which is editable (designMode = "on") and want to
resize it dynamically as the content grows (e.g. more lines of text is
in there) and there the struggle starts.

I fill the iframe with content (<body> tag and so on and also insert a
<div> tag, inbetween is the content that should be modified).

Now if the event "overflow" or "underflow" is triggered the iframe
resizes. I extract the offsetHeight of the <div> layer inside the
iframe and set the height of the iframe to that height. It seems to
work, but only if I add to the <body> of the iframe a border: 1px
dashed. and only if the scrollbar is activated (scrollbar="aut o|yes"
of the iframe).
I dont't want to see the ugly scrollbar, so I add 2px additional on
the iframe.height. Then the iframe grows as expected, but the
shrinking doesn't work if the height was mofidied with " + 2". My
code:

function resizeEditArea( ) {
newHeight = iFrame.contentW indow.document. getElementById( "content").offs etHeight;
iFrame.height = newHeight;
// iFrame.height = "" + (newHeight + 2);
/* this scales up, but not down the iframe, problem is, that the event
"underflow" is never triggered
*/
return false;
}

The iframe is created in this way:

iFrame = document.getEle mentById("editA rea");
iFrame.height = editAreaHeight;
iFrame.width = editAreaWidth;
// iFrame.scrollin g = "no"; must be enabled otherwise no event is
triggered

editArea = iFrame.contentW indow.document;
iFrame.contentW indow.addEventL istener("overfl ow", resizeEditArea,
false);
iFrame.contentW indow.addEventL istener("underf low", resizeEditArea,
false);
// iFrame.contentW indow.addEventL istener("onscro ll",
resizeEditArea, false); has no impact
iFrame.contentW indow.addEventL istener("oncont extmenu", mouseClick,
false);
editArea.write( doc);
resizeEditArea( );
editArea.close( );
editArea.design Mode = "On";
iFrame.contentW indow.focus();

Can anyone help?
Thomas

Another question is: Why is the event "oncontextm enu" never triggered,
if I click the right mouse button in the iframe?
Jul 20 '05 #1
4 7601
Look at my script:

http://djwice.com/contextmenu.html

I made an IFRAME contextmenu that dynamically changes size and that is
always on top of all elements. The functions in the contextmenu are browser
dependend.
MSIE als works with the + and - on the Num/Lock part of you keyboard.

It needs testing in Mozilla, tested in MSIE 5+ and NN 7.

Wouter
"Thomas" <ts********@hot mail.com> wrote in message
news:77******** *************** **@posting.goog le.com...
: Hi there,
:
: I have an iframe which is editable (designMode = "on") and want to
: resize it dynamically as the content grows (e.g. more lines of text is
: in there) and there the struggle starts.
:
: I fill the iframe with content (<body> tag and so on and also insert a
: <div> tag, inbetween is the content that should be modified).
:
: Now if the event "overflow" or "underflow" is triggered the iframe
: resizes. I extract the offsetHeight of the <div> layer inside the
: iframe and set the height of the iframe to that height. It seems to
: work, but only if I add to the <body> of the iframe a border: 1px
: dashed. and only if the scrollbar is activated (scrollbar="aut o|yes"
: of the iframe).
: I dont't want to see the ugly scrollbar, so I add 2px additional on
: the iframe.height. Then the iframe grows as expected, but the
: shrinking doesn't work if the height was mofidied with " + 2". My
: code:
:
: function resizeEditArea( ) {
: newHeight =
iFrame.contentW indow.document. getElementById( "content").offs etHeight;
: iFrame.height = newHeight;
: // iFrame.height = "" + (newHeight + 2);
: /* this scales up, but not down the iframe, problem is, that the event
: "underflow" is never triggered
: */
: return false;
: }
:
: The iframe is created in this way:
:
: iFrame = document.getEle mentById("editA rea");
: iFrame.height = editAreaHeight;
: iFrame.width = editAreaWidth;
: // iFrame.scrollin g = "no"; must be enabled otherwise no event is
: triggered
:
: editArea = iFrame.contentW indow.document;
: iFrame.contentW indow.addEventL istener("overfl ow", resizeEditArea,
: false);
: iFrame.contentW indow.addEventL istener("underf low", resizeEditArea,
: false);
: // iFrame.contentW indow.addEventL istener("onscro ll",
: resizeEditArea, false); has no impact
: iFrame.contentW indow.addEventL istener("oncont extmenu", mouseClick,
: false);
: editArea.write( doc);
: resizeEditArea( );
: editArea.close( );
: editArea.design Mode = "On";
: iFrame.contentW indow.focus();
:
: Can anyone help?
: Thomas
:
: Another question is: Why is the event "oncontextm enu" never triggered,
: if I click the right mouse button in the iframe?
Jul 20 '05 #2
About the height problem:

MSIE counts the border as outside the body.
NN/Mozilla counts the border as inside the body.

So if you have a border of 1px, MSIE asks you to add 2 pixels in height.
other browsers will show 2 lines below your border if you do that.
An other thing I found;
If you change focus in NN to a child, the events that you catched in the
parent will not be handled after that change via your function but via the
normal event handling of the browser.

so:

oncontextmenu=N ew function("child .focus();return false;");

will focus your child AND will open the browsers default contextmenu in NN
(not in IE).
Wouter
"Thomas" <ts********@hot mail.com> wrote in message
news:77******** *************** **@posting.goog le.com...
: Hi there,
:
: I have an iframe which is editable (designMode = "on") and want to
: resize it dynamically as the content grows (e.g. more lines of text is
: in there) and there the struggle starts.
:
: I fill the iframe with content (<body> tag and so on and also insert a
: <div> tag, inbetween is the content that should be modified).
:
: Now if the event "overflow" or "underflow" is triggered the iframe
: resizes. I extract the offsetHeight of the <div> layer inside the
: iframe and set the height of the iframe to that height. It seems to
: work, but only if I add to the <body> of the iframe a border: 1px
: dashed. and only if the scrollbar is activated (scrollbar="aut o|yes"
: of the iframe).
: I dont't want to see the ugly scrollbar, so I add 2px additional on
: the iframe.height. Then the iframe grows as expected, but the
: shrinking doesn't work if the height was mofidied with " + 2". My
: code:
:
: function resizeEditArea( ) {
: newHeight =
iFrame.contentW indow.document. getElementById( "content").offs etHeight;
: iFrame.height = newHeight;
: // iFrame.height = "" + (newHeight + 2);
: /* this scales up, but not down the iframe, problem is, that the event
: "underflow" is never triggered
: */
: return false;
: }
:
: The iframe is created in this way:
:
: iFrame = document.getEle mentById("editA rea");
: iFrame.height = editAreaHeight;
: iFrame.width = editAreaWidth;
: // iFrame.scrollin g = "no"; must be enabled otherwise no event is
: triggered
:
: editArea = iFrame.contentW indow.document;
: iFrame.contentW indow.addEventL istener("overfl ow", resizeEditArea,
: false);
: iFrame.contentW indow.addEventL istener("underf low", resizeEditArea,
: false);
: // iFrame.contentW indow.addEventL istener("onscro ll",
: resizeEditArea, false); has no impact
: iFrame.contentW indow.addEventL istener("oncont extmenu", mouseClick,
: false);
: editArea.write( doc);
: resizeEditArea( );
: editArea.close( );
: editArea.design Mode = "On";
: iFrame.contentW indow.focus();
:
: Can anyone help?
: Thomas
:
: Another question is: Why is the event "oncontextm enu" never triggered,
: if I click the right mouse button in the iframe?
Jul 20 '05 #3
"DJ WIce" <contextmenu @ djwice.com> wrote in message news:<bv******* ***@news.tudelf t.nl>...
About the height problem:

MSIE counts the border as outside the body.
NN/Mozilla counts the border as inside the body.

So if you have a border of 1px, MSIE asks you to add 2 pixels in height.
other browsers will show 2 lines below your border if you do that.
An other thing I found;
If you change focus in NN to a child, the events that you catched in the
parent will not be handled after that change via your function but via the
normal event handling of the browser.

so:

oncontextmenu=N ew function("child .focus();return false;");

will focus your child AND will open the browsers default contextmenu in NN
(not in IE).
Wouter


Thank you, I didn't know of this function. But I definitely want to
open my own context menu on the right mouse click. Right now, only the
browser menu opens. And still the iframe doesn't trigger oncontextmenu
at all.
Jul 20 '05 #4
: Thank you, I didn't know of this function. But I definitely want to
: open my own context menu on the right mouse click. Right now, only the
: browser menu opens. And still the iframe doesn't trigger oncontextmenu
: at all.

So look at the code at my website.. :-)

Wouter
Jul 20 '05 #5

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

Similar topics

1
4658
by: Martial Spirit | last post by:
Hello- I was amazed at the suckerfish drop-downs from AListApart.com. They work great except for one thing, if I position the drop-downs over an iframe element, on mouseover the menus disappear. It works fine in IE, but not FireFox. I would like to implement these menus, but if I can't get this to work, I gotta look at something else. If...
0
1919
by: Giuseppe | last post by:
Hi I've this problem Inside a winform application I've put a "webbrowser" control I've tried to catch the oncontextmenu event of the loaded HTML document with the following approach 1) In the event handler AxWebBrowser1.DocumentComplete I've put: Dim doc As mshtml.HTMLDocument
26
3205
by: shlomi.schwartz | last post by:
using this example: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Test Page</title> </head>
3
7111
by: Asterbing | last post by:
Since the "on fly addition..." thread has taken another direction, I'm opening a new one to be more explicit and recenter the subject. Well, the subject is to detect when a document is well loaded inside an iframe, knowing this document is CGI generated and that I can't modify the CGI itself (ie. add an onload event in the document body). ...
4
10609
by: lefrison | last post by:
Hi i am generating a div in my window which moves with my cursor on the screen. this works fine until i try to move the cursor over an iframe in the window. if i use the z-index the div moves in front of the iframe, but the moment the cursor is inside the iframe the div stops. i use the following code as javascript: " <script...
10
2051
by: Chris Tomlinson | last post by:
Hi all, just a quickie. I hope someone has the answer. We have about 30 images on a page, and want to apply something like this to all of them: < ... oncontextmenu="alert('Message here.');return false;" title="Another message here." ... > We want the same thing copied to every image, which basically makes for repetitive, long code...
2
3268
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...
3
5373
polymorphic
by: polymorphic | last post by:
I have succeeded in embedding PDF files in a dynamic iframe. The problem is that I need the PDF to cache. If the PDF remains the same from page load to page load then the pdf is somehow cached with the html page. But if I try to navigate to another pdf in the IFRAME then no caching occurs. Is the problem in the IFRAME reloading instead of just...
0
7435
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7694
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. ...
0
7947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7792
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...
0
5080
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...
0
3491
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...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
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...

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.