473,748 Members | 7,827 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onload event in mozilla...

Pai
hello there,

I am trying to rersize the window it works find in IE but doea not work with mozilla

window.attachEv ent(onload,MWSO nLoad);
window.onload = function (MWSOnLoad)
{
alert('hello');
window.resizeTo (810,750);
top.outerWidth= 810;
top.outerHeight =750;
}

<body marginwidth="0" marginheight="0 " scroll="yes" onload="MWSOnLo ad()">

could anybody guide me with this.

Thanks,
Srikanth pai
Jul 23 '05 #1
4 4916
Pai wrote:
hello there,

I am trying to rersize the window it works find in IE but doea not work with mozilla

window.attachEv ent(onload,MWSO nLoad);
window.onload = function (MWSOnLoad)
{
alert('hello');
window.resizeTo (810,750);
top.outerWidth= 810;
top.outerHeight =750;
}

<body marginwidth="0" marginheight="0 " scroll="yes" onload="MWSOnLo ad()">

could anybody guide me with this.


At first glance, you have duelling onloads , and I doubt if it would
work in IE, which knows nothing about top.outerWidth, And it's extremely
rude to change the user's window size.
Mick
Jul 23 '05 #2
> I am trying to rersize the window it works find in IE but doea not
work with mozilla

On Mozilla Firefox, you can set options to forbit JS to change the
window size... and I like it!

--
-Gernot

Post here, don't email. If you feel you have to mail, revert my
forename from:
to************* *************** **@invalid.com
_______________ _______________ __________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
Jul 23 '05 #3
Pai wrote:
hello there,

I am trying to rersize the window it works find in IE but doea not work with mozilla

window.attachEv ent(onload,MWSO nLoad);
window.onload = function (MWSOnLoad)
{
alert('hello');
window.resizeTo (810,750);
top.outerWidth= 810;
top.outerHeight =750;
}


I think you're doing it wrong. In your window.onload function, you're
sending MWSOnLoad as a parameter (not the name of the function).
Secondly, attachEvent is proprietary IE; the standard is addEventListene r.

What you probably meant is:
window.attachEv ent('onload', MWSOnLoad);

function MWSOnLoad()
{
Jul 23 '05 #4
Pai wrote:
I am trying to rersize the window it works find in IE but doea not work with mozilla
Usenet postings, with few exceptions like source code and URIs, should not
exceed the 80th column to be easily readable without horizontal scrolling
(if even available). If your UA does not support automatic line-break (as
Google Groups) when posting, please break your lines manually (it's best to
break them before the 80th column, 72 or 76 is recommended to allow
quotation levels be marked by ">" or another character) or use a working UA
(as a newsreader program). Read the FAQ: <http://jibbering.com/faq/>
window.attachEv ent(onload,MWSO nLoad);
window.onload = function (MWSOnLoad)
{
alert('hello');
window.resizeTo (810,750);
top.outerWidth= 810;
top.outerHeight =750;
}
This cannot work. Firstly, (window.)onload is `null' by default. You tell
the UA to attach `MWSOnLoad' which evaluates to `undefined', as it was not
defined before, to `onload' which is `null'. Thus the first line is
semantically equal to

window.attachEv ent(null, undefined);

What do you expect the UA to do then? If it does not yield a runtime error
(which is likely, see the FAQ) that statement does exactly _nothing_ useful
and you should simply omit it.

The correct syntax for window.attachEv ent() is described in the MSDN Library
(I like Firefox's location bar ;-)):

,-<http://msdn.microsoft. com/workshop/author/dhtml/reference/methods/attachevent.asp >
|
| [...]
| Syntax
|
| bSuccess = object.attachEv ent(sEvent, fpNotify)
|
| Parameters
|
| sEvent Required. String that specifies any of the standard DHTML
| Events.
| fpNotify Required. Pointer that specifies the function to call when
| sEvent fires.

You see that the first parameter/argument must be a *string* which your code
clearly is not as there are no string delimiters. You also see that the
second argument must be a "function pointer", or correctly in JScript, a
Function object reference which your code is not as no function with that
identifier was defined. That's one error. The other one that contributes
to the first error is a mix of bad syntax (looks more like fantasy syntax)
and bad style:
window.onload = function (MWSOnLoad)
{
What you do here is to define an _anonymous_ function that therefore
cannot be referred to by identifier. Since `MWSOnLoad' is located
within parantheses, it is considered to be the identifier of the
anonymous function's arguments, _not_ the function's identifier. It
works anyway in IE since you assign to a proprietary event handler
property.

The script fails in Mozilla(/5.0, I assume) since window.attachEv ent()
is part of the IE DOM and not defined in the Gecko DOM or other DOMs:

,-<ibid>
|
| There is no public standard that applies to this method.

But other HTML UAs, including Mozilla/4.0+, tend to support the proprietary
event handler properties, including "onload". So if you omit the first
line, it is likely to work. That does not mean that it must work. Besides
support for proprietary event handler properties, functionality depends on
the way the function was defined and the statements within the assigned
function. See below.
alert('hello');
What should that achieve other than irritate the user?
window.resizeTo (810,750);
That does not achieve full screen display as you might think. Instead it
irritates the user again because you manipulate his/her working environment
in an irresponsible way without asking for permission first. The size of
the browser window you try to manipulate here does not correspond in any
way with the size of the viewport and areas that correspond to it:

Display resolution != desktop size != browser window size != viewport size.
[psf 3.7]

("!=" means "not equal to" if you do not know this.)
top.outerWidth= 810;
top.outerHeight =750;
This also relates to the irresponsible manipulation of the working area I
described above. But more important, you access objects and properties of
a proprierary DOM, not parts of the language. Thus it is likely this will
yield a script error if executed in host environments that does not provide
that DOM and its objects. So you should feature-test objects and properties
before you access them, no matter if you write to them or read from them:

<http://pointedears.de. vu/scripts/test/whatami>
} <body marginwidth="0" marginheight="0 " scroll="yes" onload="MWSOnLo ad()">
"marginwidt h", "marginheig ht" and "scroll" are proprietary attributes,
meaning that they are not defined in any public version of HTML and thus
both render such markup Invalid HTML and do not work in all recent UAs as
well as likely not to work in the future. Therefore you should omit those
attributes (especially scroll="yes" is nonsense as it is the default) and
replace them by standards compliant CSS formatting:

<body style="margin:0 " onload="MWSOnLo ad()">

But now you must decide what you want: Do you want *either*

A) a reference to an anonymous function to be assigned as event listener
to the proprietary "onload" event handler property? Then omit the
standards compliant "onload" attribute here and use

window.onload = function()
{
// original code goes here
}

Note that this will not work in hosts environment that does
not support anonymous functions; you may workaround that with
either

window.onload = function MWSOnLoad()
{
// original code goes here
}

(the function is given an identifier)

or

window.onload = new Function(
"// original code goes here;"
+ "// note that some characters must be escaped"
);

(a new Function object is created directly; useful if you do not
want closures)

Note that neither works if proprietary event handler properties are
not supported.

*or* do you want

B) to use the standards compliant intrinsic "onload" event handler
attribute and call a function named "MWSOnLoad" in the event listener?
Then leave the (corrected) HTML code as is and declare the function as

function (MWSOnLoad)
{
// original code goes here
}

*before* you call it (i.e. within a "script" element as child of the
"head" element).

Note that this does not work if the "onload" attribute is ignored
(I know no browser with script support that does this).
could anybody guide me with this.

HTH

PointedEars
Jul 23 '05 #5

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

Similar topics

3
4976
by: steve | last post by:
Hi all I have this onLoad event it is working fine but I'm just queries is this the right ware to do it? <body onLoad="st_setkopcheta1(10,10,10,'stmenubottom','stmenu1','stsubmenu1' ,'stmenu2','stsubmenu2','images/crt/images/cr_04.jpg' && setDefaults())">
4
5157
by: Dariusz | last post by:
I have a page which is a mixture of PHP and Javascript, it's not a PHP problem as it is only printing the Javascript I want out to the browser. When the page executes, in Internet Explorer the onload popup event is executed successfully, but in Mozilla Firefox it does nothing at all. Anyone know what is going on? Below is the script code (carriage return deliberate to stop word wrap). Thanks
7
8874
by: Tery Griffin | last post by:
Hi all, I¹ve been away from Javascript for awhile and am rusty, but this is too simple not to work! I¹m on a Mac, and usually use the Safari browser. I have a very basic web page in a frame. All it does is trigger a Perl script. Works great in Safari, does not work in IE or Netscape. In IE, the onLoad just doesn¹t seem to fire. I¹ve got to be looking right at the reason, but I¹m not seeing it. Help? (The live frameset is at
6
4577
by: Brian | last post by:
Hi everyone, I'm writing a function (in javascript) that needs to do one thing if the page has not loaded, and another (different) thing if the page has already loaded. I'm looking for a way to tell if the window.onload event has already fired. I cannot edit the onload event handler itself, and my function can only exist in an external js file, sourced from the document's head section. Any ideas?
3
2002
by: Disco-181 | last post by:
Hi, I have a script which isn't working in Mozilla based browser for some reason. I'm trying to run two functions from the body onload tag and it simply isn't happening. I have a cascading menu, where the primary dropdown selection determines the contents of a second dropdown. This is triggered by a function in the onchange tag of the primarys select tag. When triggered like this, the function and drop downs work fine. When
9
28941
by: Sunny | last post by:
Hi, I have cr8ed a javascript function in the head section of a jsp page. <!-- function go(theURL) { alert(theURL); if (theURL!=null){
1
6161
by: bjarthur | last post by:
i have (see below) what i think is a fairly simple algorithm, but yet it doesn't work. given a directory with consecutively numbered jpeg files (1.jpg, 2.jpg, 3.jpg...), it is designed to count how many files there are using a binary search. it uses the onload and onerror event handlers of the image object to see if the files successfully loaded or not. testing on a macintosh (os x 10.3.8) with a directory of 39 files, IE 5.2 and...
2
6479
by: Martin Honnen | last post by:
I was playing around with canvas support in recent Safari, Mozilla and Opera (only version 9 preview) but run into issues with Safari related to the very old DOM Level 0 Image object for preloading images. When doing e.g. var img = new Image(); img.onload = function (evt) { alert(this); }; img.src = 'whatever.gif';
6
19308
by: Daz | last post by:
Hello everyone, I would like to open a child window from the parent, and add an onload event listener to the child window which will tell the parent when the document has loaded. As far as I know, this shouldn't be an issue, but I just can't get it to work. The script only needs to work with Firefox/Mozilla, so XP code isn't an issue. I have tried to open a window like so.
0
8987
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
8826
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
9366
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
9316
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
9241
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
8239
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
6793
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
6073
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();...
2
2777
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.