hello there,
I am trying to rersize the window it works find in IE but doea not work with mozilla
window.attachEvent(onload,MWSOnLoad);
window.onload = function (MWSOnLoad)
{
alert('hello');
window.resizeTo(810,750);
top.outerWidth=810;
top.outerHeight=750;
}
<body marginwidth="0" marginheight="0" scroll="yes" onload="MWSOnLoad()">
could anybody guide me with this.
Thanks,
Srikanth pai 4 4859
Pai wrote: hello there,
I am trying to rersize the window it works find in IE but doea not work with mozilla
window.attachEvent(onload,MWSOnLoad); window.onload = function (MWSOnLoad) { alert('hello'); window.resizeTo(810,750); top.outerWidth=810; top.outerHeight=750; }
<body marginwidth="0" marginheight="0" scroll="yes" onload="MWSOnLoad()">
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
> 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
Pai wrote: hello there,
I am trying to rersize the window it works find in IE but doea not work with mozilla
window.attachEvent(onload,MWSOnLoad); 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 addEventListener.
What you probably meant is:
window.attachEvent('onload', MWSOnLoad);
function MWSOnLoad()
{
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.attachEvent(onload,MWSOnLoad); 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.attachEvent(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.attachEvent() 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.attachEvent(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.attachEvent()
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="MWSOnLoad()">
"marginwidth", "marginheight" 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="MWSOnLoad()">
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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'...
|
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...
|
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. ...
|
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...
|
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...
|
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){
|
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...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: SueHopson |
last post by:
Hi All,
I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...
| |