473,776 Members | 2,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does Event handlers work in netscape.

Does Event handlers work in netscape. If yes means can anyone please
help me.

<HTML><SCRIPT LANGUAGE="JScri pt">
function mouseclick() {
alert("I was clicked on " + window.event.sr cElement.tagNam e);
}
</SCRIPT>
<BODY onclick="mousec lick()">
<H1>Welcome!</H1>
<P>This is a very <B>short</B> document.

</BODY>
</HTML>

The above script works fine in IE

But not in Netscape 7.2 :((

Jul 23 '05 #1
9 1773
testing

Jul 23 '05 #2
ch************* **@gmail.com wrote:
The above script works fine in IE
But not in Netscape 7.2 :((


Try this modification:

function mouseclick(e) {
var what = e.target || e.srcElement;
if (what) alert("I was clicked on " + what.tagName);
}
[...]
<body onclick="mousec lick(event)">

ciao, dhgm
Jul 23 '05 #3
Dietmar Meier wrote:
ch************* **@gmail.com wrote:
The above script works fine in IE
But not in Netscape 7.2 :((

Try this modification:

function mouseclick(e) {


if (!e && window.event) var e = window.event;

I'm not near an IE box right now, but I think to keep IE happy you'll
need to add the above line before:
var what = e.target || e.srcElement;

[...]

I'm playing in Safari at the moment, it seems to support a bit of both
Firefox/Netscape and IE (but often neither...) so I can't test it in
IE.

You may only need the extra line if you don't pass 'event' with the
onclick call.
--
Rob
Jul 23 '05 #4


ch************* **@gmail.com wrote:
Does Event handlers work in netscape.
Yes, event handlers work in Netscape, depending on the Netscape version
not all event handlers specified in HTML 4 might work but with Netscape
6/7 there is certainly support for HTML 4 and for DOM Level 2 Events.
<HTML><SCRIPT LANGUAGE="JScri pt">
function mouseclick() {
alert("I was clicked on " + window.event.sr cElement.tagNam e);
Have you checked the JavaScript console? It probably shows you that
window.event
is undefined or not an object with Netscape 6/7
<BODY onclick="mousec lick()">


so the problem is not that the onclick handler is not being fired but
that your script being called then throws an error.
You can pass the event object to a function e.g.
<body onclick="mousec lick(event);">
and then you need to process that argument in the function e.g.
function mouseclick (evt) {
and then you need to be aware that properties of the event object differ
in IE and in Netscape, IE docs are here:
<http://msdn.microsoft. com/library/default.asp?url =/workshop/author/dhtml/reference/objects/obj_event.asp>
Netscape 6/7 implements the W3C DOM as given here:
<http://www.w3.org/TR/DOM-Level-2-Events/events.html#Eve nts-Event>
<http://www.w3.org/TR/DOM-Level-2-Events/events.html#Eve nts-UIEvent>
<http://www.w3.org/TR/DOM-Level-2-Events/events.html#Eve nts-MouseEvent>

You already got an answer showing to access target with Netscape (or
other browser supporting that) and srcElement with IE (or other browsers
supporting that).
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #5


RobG wrote:
Dietmar Meier wrote:
Try this modification:

function mouseclick(e) {

if (!e && window.event) var e = window.event;

I'm not near an IE box right now, but I think to keep IE happy you'll
need to add the above line before:
var what = e.target || e.srcElement;

You may only need the extra line if you don't pass 'event' with the
onclick call.


And Dietmar had
<body onclick="mousec lick(event)">
in his answer so your line is not needed with his solution.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #6
Martin Honnen wrote:
ch************* **@gmail.com wrote: <snip>
<HTML><SCRIPT LANGUAGE="JScri pt">

^^^^^^^
<snip> ... but
that your script being called then throws an error.

<snip>

The script certainly would error if executed in Netscape/Mozilla, but
would they execute script specified as language="JSCRI PT" in the first
palace?

Richard.
Jul 23 '05 #7
Thanks for your code. But its not working in Netscape, same problem

Jul 23 '05 #8
ch************* **@gmail.com wrote:
Thanks for your code. But its not working in Netscape, same problem


In addition to my code, see Richard's answer. Instead of

<SCRIPT LANGUAGE="JScri pt">

(which is MSIE-proprietary) you should use

<script type="text/javascript">

to have your code executed in both Netscape7 and MSIE (and
other browsers). A complete example document would be:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Script-Type"
content="text/javascript">
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
<title></title>
<script type="text/javascript">
function mouseclick(e) {
var what = e.target || e.srcElement;
if (what) alert("I was clicked on " + what.tagName);
}
</script>
</head>
<body onclick="mousec lick(event)">
<H1>Welcome!</H1>
<P>This is a very <B>short</B> document.
</body>
</html>

ciao, dhgm
Jul 23 '05 #9


Richard Cornford wrote:

ch*********** ****@gmail.com wrote:


<HTML><SCRIP T LANGUAGE="JScri pt">


^^^^^^^

The script certainly would error if executed in Netscape/Mozilla, but
would they execute script specified as language="JSCRI PT" in the first
palace?


Good catch, Mozilla indeed ignores such a script block.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #10

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

Similar topics

3
10179
by: Edwin Boersma | last post by:
Hi, I've just installed Netscape 7.1 for Linux and the following script refuses to open a window when I call this function: function OpenLinkWindow() { wMap=window.open('http://naxos.orangeport.net/cyclades-info/ShowMap.php?id_advert=45&map=','','width=400,height=600'); wMap.onResize = 'self.location.href=http://naxos.orangeport.net/cyclades-info/ShowMap.php?id_advert=45&map='
6
11342
by: Fredrik Celin | last post by:
If I add an event (to a div for example) with js, it replaces the event if there already is one. How can I add instead of replace this? Example: <body onLoad="testDiv.onmouseover = (function(event){alert('helloAgain')});"> <div id="testDiv" onMouseOver="alert('hello');">JaJa!</div>
2
1275
by: Ron D | last post by:
What is the equivalent of if (window.event.srcElement.id == "txt1ST_INIT_NM") in Netscape?
6
2339
by: Amir Hardon | last post by:
I am dynamically adding rows to a table, and each row have a button which removes it. I have successfully implemented this for mozilla but I'm having troubles with IE, here is how I did it: Each new row's id is an index number, each button's name is the row's id, and I'm adding this function as the click event listener for the button: function removeline(event){ var row=document.getElementById("row" + event.target.name);
11
2030
by: Saqib Ali | last post by:
Please excuse me, this is a fairly involved question that will likely require you to save the file below to a file and open it in a browser. I use Mozilla 1.5, so the problem I describe below should be reproducible with that version at least. BACKGROUND: =========== When you open this page in your browser, you will see a 4 cell table. The cells contain the following items respectively:
3
13062
by: Lachlan Hunt | last post by:
Hi, I've been looking up lots of documentation and trying to work out a cross-platform method of capturing a keyboard event and working out which key was pressed. From what I can find, there doesn't appear to be any standardised keyboard event interface other than this DOM 3 Events W3C Working Group Note . However, it is only a note and doesn't appear to be implemented in any browser. Is there another standard that I've missed? The...
9
5735
by: VK | last post by:
My original idea of two trains, however pictural it was, appeared to be wrong. The truth seems to be even more chaotic. IE implements its standard down-up model: any mouse event goes from the deepest visible element to the top. By carefully studying fromElement and toElement properties, one can handle events on any point of their way up. NN/FF implements a "Russian hills" style: mouse events go first up->down (window->deepest...
3
2435
by: interuser | last post by:
Hi How can I prevent an event (eg button click) from happening from within page_load? The reason is that I want to make my existing application work for netscape, for which there are no client side validations. So I thought to put something like the following in the superclass of all UI pages: public sub page_load
3
1569
by: Islam Elkhayat | last post by:
I have master datagrid & master details in 5 panels each belong to diffrent dbtable. I have a dropdpwn list to switch which panel to be visible.. I also have one navigation bar for add, update, delete and i need to the button to work with the visible panel but the click event don't fire, here is my code for the dropdownlist selectedindex change: private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e) {
0
9625
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9459
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
10117
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...
1
10056
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
8948
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...
0
6721
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
5365
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
5489
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4027
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

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.