473,786 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

captureEvents in Netscape 7

Hey everyone,

I have trouble capturing events in Netscape 7.1.

I am building a WYSIWYG editor thingy which should both work in IE and
NS 7. For this I use designMode='on' . However, it seems like as soon as
I do that, it stops capturing events from that element.

//
// EditGUI is a simple WYSIWYG editor for chat
///////////////////////////////////////////////////////////////

function EditGUI() {
this.document = null;
this.window = null;
this.body = null;
this.content = null;

this.writeHere = function(width, height, className)
{
iframe = writeIFrame(wid th,height, className);
this.window = iframe.contentW indow;
this.document = this.window.doc ument;
this.body = this.document.b ody;
// make it editable
if ("contentEditab le" in this.body) {
// IE
this.content = this.document.c reateElement('P ');
this.content.co ntentEditable = true;
this.body.appen dChild(this.con tent);
} else if ("designMode " in this.document) {
// NS 7
this.content = this.document.b ody;
this.document.d esignMode = "on";
}

// install callback reference
this.document.b ackRef = this;

if ("captureEvents " in this.document) {
this.document.c aptureEvents(Ev ent.KEYPRESS);
}

this.document.o nkeypress = function(event) {
event = (event!=null?ev ent:window.even t);
this.backRef.ke y(event);
}
}

this.key = function(event) {
alert('yes, you pressed a key!');
}
}

//
// appends an iframe to the current part of the document and
// returns its reference.
/////////////////////////////////////////////////////////////////

function writeIFrame(wid th, height, className) {
iframe = document.create Element('IFRAME ');
if (className) iframe.classNam e = className;
iframe.style.wi dth=width;
iframe.style.he ight=height;
document.body.a ppendChild(ifra me);
doc = iframe.contentW indow.document;
doc.open();
doc.close();
return iframe;
}

Now this works perfectly in Internet Explorer. But whatever I try, I
can't get Netscape to display 'yes, you pressed a key'. There are no
errors either. It does work if I turn designMode off. Anyone have any idea?

Thanks in advance,
Vincent

Jul 23 '05 #1
6 2219


Vincent van Beveren wrote:

[captureEvents]
I have trouble capturing events in Netscape 7.1.


The method captureEvents is part of the Netscape 4 event model/api, it
also somehow made it into Mozilla and Netscape 6/7 but shouldn't be used
there as they implement the W3C DOM Level 2 event model/api which has
its own way to capture events i.e.
document.addEve ntListener(
'keypress',
function (evt) {
alert(evt.type) ;
},
true
);
Looking at your code I don't think you really want to use event
capturing in the sense of the DOM Level 2 event model but simply want to
handle the keypress event at the document node so you can probably use
false instead of true above.
I haven't tested whether handling key events with Netscape 7 works
properly in an iframe with designMode editing enabled but if it doesn't
that is most certainly not a problem cured with captureEvents in any
way. You might want to search bugzilla.mozill a.org whether there are any
bugs filed for key event handling in editable iframes maybe they have
been fixed after Netscape 7.1 (which is based on Mozilla 1.4).
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2
Thanks for your quick reply.
The method captureEvents is part of the Netscape 4 event model/api, it
also somehow made it into Mozilla and Netscape 6/7 but shouldn't be used
there as they implement the W3C DOM Level 2 event model/api which has
its own way to capture events i.e.
The captureEvents was a last resort. I also included it so people
wouldn't reply with 'did you try to use captureEvents'.

I tried your code, but then it doesn't work at all, not even in IE.

this.document.a ddEventListener ('onkeypress',
function(event) {
event = (event!=null?ev ent:window.even t);
this.backRef.ke y(event);
}, true); // also tried false
Neither does it give any error... hmm...

You might want to search bugzilla.mozill a.org whether there are any
bugs filed for key event handling in editable iframes maybe they have
been fixed after Netscape 7.1 (which is based on Mozilla 1.4).


That could be. But even if it wouldn't solve it. It needs to run for an
as broad audience as posssible.

any other ideas?

Vincent

Jul 23 '05 #3


Vincent van Beveren wrote:

> The method captureEvents is part of the Netscape 4 event model/api, it
> also somehow made it into Mozilla and Netscape 6/7 but shouldn't be used
> there as they implement the W3C DOM Level 2 event model/api which has
> its own way to capture events i.e.


The captureEvents was a last resort. I also included it so people
wouldn't reply with 'did you try to use captureEvents'.

I tried your code, but then it doesn't work at all, not even in IE.


Well, I have not suggested to use addEventListene r for IE.
addEventListene r is part of the W3C DOM Level 2 events model and IE
doesn't implement that.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #4


Vincent van Beveren wrote:

I tried your code, but then it doesn't work at all, not even in IE.

this.document.a ddEventListener ('onkeypress',
function(event) {
event = (event!=null?ev ent:window.even t);
this.backRef.ke y(event);
}, true); // also tried false


I have made a short example at
http://home.arcor.de/martin.honnen/j...t20040528.html
and here with Netscape 7.1, some Mozilla 1.7a and Firefox 0.8 all on
Windows the keypress event listener is called when I type in the iframe.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #5
Vincent van Beveren wrote:

Please provide proper attribution. A line including the
author of the quoted material is sufficient (see above).
vvvvvvvvvvvvvvv vvvvvvvvvvvvvvv vvvvvvvvvvvvvvv vvvvvvvvvvv
The method captureEvents is part of the Netscape 4 event model/api, it
also somehow made it into Mozilla and Netscape 6/7 but shouldn't be used
there as they implement the W3C DOM Level 2 event model/api which has
its own way to capture events i.e.
The captureEvents was a last resort. I also included it so people
wouldn't reply with 'did you try to use captureEvents'.

I tried your code, but then it doesn't work at all, not even in IE.

this.document.a ddEventListener ('onkeypress',


The event identifier is "keypress", its intrinsic handler is
"onkeypress ". addEventListene r() expects the identifier, not
the handler.
function(event) {
event = (event!=null?ev ent:window.even t);
this.backRef.ke y(event);
Looks like fantasy syntax.
}, true); // also tried false
Neither does it give any error... hmm...


1. Why should it? There could be an "onkeypress " event in a DOM.
2. Maybe it does. Watch Mozilla's JavaScript console.
PointedEars
Jul 23 '05 #6
Thanks everyone for replying!

Vincent van Beveren wrote:
this.document.a ddEventListener ('onkeypress',
function(event) {
event = (event!=null?ev ent:window.even t);
this.backRef.ke y(event);
}, true); // also tried false


The problem was that it should have been 'keypress' and not
'onkeypress'. Now it works perfectly, though I had to make
an exception for IE. I wrote the following code:

this.document.b ackRef = this;
this.document.o nkeyup = function(event)
{
event = (event?event:th is.parentWindow .event);
this.backRef.ke yUp(new WrappedEvent(ev ent));
};

if (this.document. addEventListene r) {
this.document.a ddEventListener ('keyup', this.document.o nkeyup,
false);
}

I choose key up later, cause it suited the cause better.
The wrappedEvent object is a generic event object so that I
don't need to worry about incompatibility issues. (blah)

I wish that IE was somewhat more DOM complient.

Thanks,
Vincent

Jul 23 '05 #7

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

Similar topics

1
5036
by: Sims | last post by:
Hi, if i use... // php $info = getenv("HTTP_USER_AGENT"); // I noticed that Mozzila and Netscape <6(?) both use the same Agent. // so i was thinking of if (preg_match("/Mozilla/i", $info)) {
6
13843
by: Dave | last post by:
Hi, With this code, I thought that any 'click' with the mouse would be captured on the window level and nothing would happen, but a click on the button triggers nevertheless the function hit(). Why is it not directed to the function IgnoreEvents instead of the function hit? .... <script> window.top.captureEvents(Event.CLICK) window.top.onclick=IgnoreEvents
9
2555
by: rez | last post by:
I find it rather frustrating that Netscape 4.x is "no longer supported:" http://help.netscape.com/products/client/communicator/reflib.html Same seems true with IE. How am I ever supposed to make my scripts multi-browser, when they don't bother giving me basic documentation?
2
3097
by: Phil | last post by:
Hello all ! I need help with this script : It's a tooltip appearing onMouseOver on a link. It works fine in IE, Opera but not Netscape 7 and Mozilla 1.5. The tooltip sticks on the top left corner of the window. Any help appreciated :-) Thanks
2
1430
by: ALuPin | last post by:
Hi, when I try to see the effect of the following script I do not see anything when using Netscape Navigator whereas InternetExplorer ist ok. In Netscape Javascript is activated. What could be the problem? Thank you for your help.
2
2611
by: Obi Wan Shinobi | last post by:
I can't seem to prevent the refresh associated with F5 in Netscape. I can capture the key but returning false does not prevent the refresh. The code is as follows: function keyDown(e) { if (navigator.appName == 'Netscape') { if(e.which == 116) { alert('This action is prohibited'); e.cancelBubble = true;
2
3384
by: harry | last post by:
Hi I am trying to add an event handler to the window so that If the user clicks the close window button, it creates a popup to tell the user it should use the log out button before closing window. When I try to this: window.captureEvents(Event.CLICK); I get a javascript error saying the "Event" is undefined. Here is how I use the code
10
2376
by: News | last post by:
I have a page up trying to learn how to ID a browser and other info. http://wyght.com/warren/testPos.html here is the code <script type = "text/javascript"> var space = ", "; var name = navigator.appName;
4
1837
by: Nathan Sokalski | last post by:
I was testing out a page of mine that displays the information from Page.Request.Browser. It works exactly as I expected in Internet Explorer and Netscape 4.75 (I didn't expect much in Netscape 4.75, but I got some stuff). However, Netscape 7.1 gave me some strange stuff, including the following: 1. It gave the Version as 5.0 rather than 7.1, and the Type as Netscape5 2. ASP.NET did not send any CSS other than the constant part that I...
0
9497
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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...
0
10164
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7515
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
6748
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
5398
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...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
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.