473,385 Members | 1,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Catching window events

hi all,

This is about javascript window events. I have a simple html file like
this
<html>
<head>
</head>
<body onmousedown="alert()">
<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 4137
<vi*****@gmail.com> skrev i meddelandet
news:11*********************@z14g2000cwz.googlegro ups.com...
hi all,

This is about javascript window events. I have a simple html file like
this
<html>
<head>
</head>
<body onmousedown="alert()">
<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:100%;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.com wrote:
Hi Joakim,

I tried adding body style="height:100%;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.onmousedown = 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.com wrote:
hi all,

This is about javascript window events. I have a simple html file like
this
<html>
<head>
</head>
<body onmousedown="alert()">
<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.mousedown rather
than window.mousedown, however I do not know what the browser
limitations are on this, mozilla firefox 1.0.3 accepts
document.mousedown, 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.com wrote:
hi all,

This is about javascript window events. I have a simple html file like this
<html>
<head>
</head>
<body onmousedown="alert()">
<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.getElementsByTagName('html')[0].onmousedown =
function(e)
{
e = e || window.event;
tgt = e.srcElement || e.target;
alert(tgt.tagName);
}
</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.com wrote:
I tried adding body style="height:100%;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:absolute, too. Tests (with
ObjectInspector) showed that the following stylesheet is suited for
the task:

body {
position:absolute;
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
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...
1
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...
5
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...
1
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'...
3
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...
0
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...
3
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. ...
5
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...
0
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.