473,938 Members | 20,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching window events

hi all,

This is about javascript window events. I have a simple html file like
this
<html>
<head>
</head>
<body onmousedown="al ert()">
<form>
<input type="text">
</form>
</body>
</html>

But alert is only popped whenever I click the mouse near by the input
field. It is not catching the event for the entire browser window. Can
anyone point out what is wrong in this html?

Thanks,
Vijay

Jul 23 '05 #1
9 4185
<vi*****@gmail. com> skrev i meddelandet
news:11******** *************@z 14g2000cwz.goog legroups.com...
hi all,

This is about javascript window events. I have a simple html file like
this
<html>
<head>
</head>
<body onmousedown="al ert()">
<form>
<input type="text">
</form>
</body>
</html>

But alert is only popped whenever I click the mouse near by the input
field. It is not catching the event for the entire browser window. Can
anyone point out what is wrong in this html?


The answer is probably that the body by default doesn't extend to fill the
entire browser window.

Try adding some CSS that makes height/width of body 100%.

--
Joakim Braun
Jul 23 '05 #2
Hi Joakim,

I tried adding body style="height:1 00%;width:100%" to the body tag.
Now, it is always displaying scroll bars inside the explorer. It is
also not truly encompassing the whole browser window. It's 0,0
coordinates seem to be startting from the point text box appears. The
thin margins on the top left are not capturing the event.

Is there some way by which I can add the eventhandler to the window
itself and not just body? I think I have seen such pages where they do
such stuff.

Thankyou for helping...

Jul 23 '05 #3

vija...@gmail.c om wrote:
Hi Joakim,

I tried adding body style="height:1 00%;width:100%" to the body tag.
Now, it is always displaying scroll bars inside the explorer. It is
also not truly encompassing the whole browser window. It's 0,0
coordinates seem to be startting from the point text box appears. The
thin margins on the top left are not capturing the event.

Is there some way by which I can add the eventhandler to the window
itself and not just body? I think I have seen such pages where they do such stuff.

Thankyou for helping...


Try:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-GB">
<head>
<title>Window Alert</title>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<script type="text/javascript">
window.onmoused own = function() { alert("This will get really
irritating."); };
</script>
</head>
<body>

</body>
</html>

Jul 23 '05 #4
Hi Bonnett,

This is running really well on Mozilla but I don't know why it is not
doing anything on Internet Explorer. Looks like IE is completely
ignoring this. Any guesses why so...

Thankyou very much,

Jul 23 '05 #5
vi*****@gmail.c om wrote:
hi all,

This is about javascript window events. I have a simple html file like
this
<html>
<head>
</head>
<body onmousedown="al ert()">
<form>
<input type="text">
</form>
</body>
</html>

But alert is only popped whenever I click the mouse near by the input
field. It is not catching the event for the entire browser window. Can
anyone point out what is wrong in this html?

Thanks,
Vijay


<style type="text/css">
body {border: 0; margin: 0; width: 100%; height: 100%;}
</style>

If IE persists with scrollbars, reduce width/height to 99%. IE 5.2
on Mac doesn't show scrollbars at 100%.

--
Fred
Jul 23 '05 #6
After a quick google + test, it seems IE uses document.moused own rather
than window.mousedow n, however I do not know what the browser
limitations are on this, mozilla firefox 1.0.3 accepts
document.moused own, but older version may not.

Jul 23 '05 #7
Hi Bonnet and Fred,
Many thanks for fishing this out. I have got what I wanted.
Thanks,

Jul 23 '05 #8
vija...@gmail.c om wrote:
hi all,

This is about javascript window events. I have a simple html file like this
<html>
<head>
</head>
<body onmousedown="al ert()">
<form>
<input type="text">
</form>
</body>
</html>

But alert is only popped whenever I click the mouse near by the input
field. It is not catching the event for the entire browser window. Can anyone point out what is wrong in this html?

Thanks,
Vijay


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/str*ict.dtd">
<html>
<head>
<style type="text/css">
html { padding: 20px; cursor: help; }
body { margin:0; height:100%; }
input { cursor: help; }
</style>
<script type="text/javascript">
document.getEle mentsByTagName( 'html')[0].onmousedown =
function(e)
{
e = e || window.event;
tgt = e.srcElement || e.target;
alert(tgt.tagNa me);
}
</script>
</head>
<body>
<form>
<input type="text">
</form>
</body>
</html>

http://www.meyerweb.com/eric/css/dis...all-shown.html
http://www.molly.com/2005/02/18/root-element-html/

btw moz/gecko requires arguments to alert(...)

Jul 23 '05 #9
vi*****@gmail.c om wrote:
I tried adding body style="height:1 00%;width:100%" to the body tag.
Now, it is always displaying scroll bars inside the explorer.


1. [X] You only know Internet Explorer. [psf 2.9]

<OT>

2. You have to format the element position:absolu te, too. Tests (with
ObjectInspector ) showed that the following stylesheet is suited for
the task:

body {
position:absolu te;
margin:0;
width:99%;
height:99%;
}

html>body {
width:auto;
height:auto;
left:0;
top:0;
right:0;
bottom:4px;
}

</OT>
PointedEars
Jul 23 '05 #10

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

Similar topics

0
893
by: Ayende Rahien | last post by:
How do I catch events from a web browser hosted in my application? I host it by adding a reference to SHDocVw and then adding it to my form. Right now I can tell it to fetch a page using Navigate2() and show my html using (IPersistStreamInit)->Load(). I want to know how I hock to events that are happening, so I can show on my status bar when hover on a link, or open a new browser window when clicking on a link. Doing it using C#, but I...
1
1416
by: Sylvian Stone | last post by:
Hi, I suspect that this may not be possible, but this is my little problem. I have a main page ('index.php') with an iframe ('mainframe') on the left hand side. All the links on the index page load a new page of mainly text content into the iframe. All pretty straightforward, but I am using some javascript to launch
5
2271
by: Ron L | last post by:
I have an MDI application with a number of child windows. In each child window I am catching the Closing event and having the child window decide if it should set cancel to true. The intent here is to ensure that no child window can close while it is in a state where user entered information can be lost. I have just noticed that while the Closing event is caught if I click the X on the child window, it is not caught if I click the X on...
1
7844
by: Chris LaJoie | last post by:
Hi, I have a question regarding the catching of popups in a separate window. I just can't get it to work. My browser is extremely simple and is designed for a single purpose: to open a 'netlet' to a particular VPN on the United Airlines network. The trouble is, I can't get my app to catch the popup (which is the netlet). The netlet opens outside in a separate IE window instead. I have a VB6 app that does what I want perfectly fine...
3
1903
by: yuval | last post by:
Hi DragDrop event is fired by the control accepting the drop If the drop is performed outside the controls I'm watching with events (like on another control/panel/window or outside my app) is there a way for me to know about it? (In MFC, for example, mouse movements are captured) Or do I just have to follow DragEnter/DragLeave and deduce from that?
0
1057
by: TimSLC | last post by:
I have an application that automates the testing of form filling on a web page. This part works great using axWebBrowser and such. What I am trying to do is catch when Java Events occur and log what the event was. More specifically, when filling out certain forms an alert() event is called and pops up a window with a message. Is there a way that I can get the application to see when these events happen, still allow the event to happen, log...
3
5185
by: Robert Inder | last post by:
I am struggling to catch kestrokes within an Internet Explorer 6 window. My window happens to be displaying three frames, though I suspect a similar problem would arise with a single document. The "<body.." tag in each frame includes an "onKeyPress" handler to catch and act on key presses. And if I focus the window by clicking on the content of one of the documents, keystrokes are sent to the handler on its "<body..." tag.
5
2618
by: lord.zoltar | last post by:
How can I prevent the big close button in the top of the window from closing the window? I want to have and "are you sure?" confirmation so the user must press "Yes" before the program ends. Right now, I've tried catching the FormClosing and FormClosed events. The message box appears at the right time, but since the form is already closing, it doesn't matter if the user presses "Yes" or "No". how do I cancel the FormClosing?
0
1283
by: avgasman | last post by:
Hi all, I am a very novice c# programmer trying to use the mouse event args to place a graphic on a directshow video window. As soon as the mouse enters the active video panel, I lose ability to get mouse data. Can anyone help me retain mouse data within an active video window. Thanks
0
10134
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
9963
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
11106
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
10657
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...
0
9857
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
8218
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
7384
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
6295
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.