473,396 Members | 1,755 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,396 software developers and data experts.

onLoad not triggering in IE

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
http://www.wsc.ma.edu/webstudents/Co...e_frameset.htm .)

TIA,
Tery

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>comm test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<SCRIPT language="JavaScript">
function submitform()
{
document.form.submit();
}
</SCRIPT>

</head>

<body bgcolor="#330099" onLoad="submitform()">

<form name="form" action="randomimages_2.pl">
</form>
</body>
</html>

Jul 23 '05 #1
7 8852
In article <BC**********************@cox.net>, Tery Griffin
<te********@cox.net> wrote:
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
http://www.wsc.ma.edu/webstudents/Co...e_frameset.htm .)

TIA,
Tery

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>comm test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<SCRIPT language="JavaScript">
function submitform()
{
document.form.submit();
}
</SCRIPT>

</head>

<body bgcolor="#330099" onLoad="submitform()">

<form name="form" action="randomimages_2.pl">
</form>
</body>
</html>

It triggers in both IE5.1 and Netscape7.0 on my Mac with system 9 but
you should add type="text/javascript" to the script tag.
Also check if onLoad should be onload. All tags should be lowercase.

--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 23 '05 #2
On 4/24/04 9:32 PM, in article 24*************************@domain.invalid,
"Dennis M. Marks" <de******@domain.invalid> wrote:
It triggers in both IE5.1 and Netscape7.0 on my Mac with system 9 but
you should add type="text/javascript" to the script tag.
Also check if onLoad should be onload. All tags should be lowercase.

Thanks Dennis. I made both changes. No difference for me. I'm on OS
X.2.8, IE 5.3, Netscape 7.1. I'll be this happened with the switch to OS X.

Tery

Jul 23 '05 #3
Terry,

I pretty much avoid using onLoad events any where. There always seems
to be one browser that fails. Currently there is an open bug with
Mozilla that I've been tracking - 99820.

Instead now I now just add my own onLoad call. The following code
after the closing body tag:

<script>
// Your'e onload script here.
</script>

I've had this on production and tested it on Mozilla (OSX, win32,
Linux), IE (win32).

There should be no reason that it will not work in Safari or IE Mac.

BTW - For Cleanliness, I usually add a bodyLoaded function at the top
of the page or in a JS file and call it from the script tag after the
close body tag.

Regards,

Tim
Jul 23 '05 #4
Java script Dude wrote:
<snip>
Instead now I now just add my own onLoad call. The following code
after the closing body tag: ^^^^^
<script>
// Your'e onload script here.
</script>
The HTML DTDs do not allow script elements to appear as children of the
HTML element. The result of doing this is invalid HTML mark-up.
I've had this on production and tested it on Mozilla (OSX, win32,
Linux), IE (win32).

There should be no reason that it will not work in Safari or IE Mac.

<snip>

There is every reason for expecting it to fail; if not in Safari or Mac
IE then somewhere. There are no rules for the handling of invalid
mark-up by web browsers so the browser is a liberty to do anything,
including ignoring the out of context script element, and nobody could
say it is wrong for it to do so. Relying on browser error-correcting
cannot reasonably be recommended as a technique for achieving reliable
results.

Richard.
Jul 23 '05 #5
> Richard Cornford wrote:
Java script Dude wrote:
<snip>
Instead now I now just add my own onLoad call. The following code
after the closing body tag:

^^^^^

<script>
// Your'e onload script here.
</script>


There is every reason for expecting it to fail; if not in Safari or Mac
IE then somewhere. There are no rules for the handling of invalid
mark-up by web browsers so the browser is a liberty to do anything,
including ignoring the out of context script element, and nobody could
say it is wrong for it to do so. Relying on browser error-correcting
cannot reasonably be recommended as a technique for achieving reliable
results.


I agree. If the end goal of the page is to work in a majority of the
browsers that request it, this is not a good technique. But I think we
are still years away when we (as developers) can make complex DHTML
applications that work in a majority of browsers. To build really
maintainable and effective DHTML Apps, the compatible browser list
must be narrowed.

At this time, Mozilla and IE never complain about putting code there
and I am pretty sure with enough nagging, W3C could be convinced that
it's not such a bad idea to allow script tags after the closing body
tag. I have not had the time, nor the need, to test multiple browsers
compatibility. Just IE 5.5sp2+ and Moz 1.3+. At least this could be
used as a back door to the body's onload event.

Maybe I'm way off here ?:]
Jul 23 '05 #6
Java script Dude wrote:
Richard Cornford wrote:
Java script Dude wrote:
<snip>
Instead now I now just add my own onLoad call. The following code
after the closing body tag: ^^^^^

<script>
// Your'e onload script here.
</script>

You have edited my post here without indicating that you have done so,
moving my response to a direct statement of yours out of its original
context.
There is every reason for expecting it to fail; if not in Safari or
Mac IE then somewhere. There are no rules for the handling of invalid
mark-up by web browsers so the browser is a liberty to do anything,
including ignoring the out of context script element, and nobody
could say it is wrong for it to do so. Relying on browser
error-correcting cannot reasonably be recommended as a technique for
achieving reliable results.


I agree. If the end goal of the page is to work in a majority of the
browsers that request it, this is not a good technique. But I think we
are still years away when we (as developers) can make complex DHTML
applications that work in a majority of browsers.


That depends on how you define the majority of browsers. if it is just
browsers in use then there are many who argue that IE is already the
majority, if you mean the majority of distinct browsers then the
majority are not javascript capable so DHTML was never going to work for
them.
To build really
maintainable and effective DHTML Apps, the compatible browser list
must be narrowed.
There are a number of practices that are known to impact on the
reliability of browser scripts, one of which is the use of invalid
mark-up. If DHTML support is going to be restricted then there really
should be a better reason for reducing it below support for all
javascript capable dynamic browsers than an unwillingness to author
structurally valid HTML.
At this time, Mozilla and IE never complain about putting code there
and I am pretty sure with enough nagging, W3C could be convinced that
it's not such a bad idea to allow script tags after the closing body
tag.
The expression "a snowball's chance in hell" springs to mind. The W3C
seem to want to increase the requirements for formal correctness in web
authoring (at least the move towards XHTML implies as much) and they
also seem to like the idea of semantic mark-up. A primary document
division of HEAD, BODY and SCRIPT, with script also allowed in many
other contexts, would not sit well with that goal.
I have not had the time, nor the need, to test multiple browsers
compatibility. Just IE 5.5sp2+ and Moz 1.3+. At least this could be
used as a back door to the body's onload event.


There is no fundamental problem with Mac OS X onload handlers in IE 5
and Safari, they work fine when I test them. Where onload handlers fail
is when a browser is used in conjunction with a
content-inserting/re-writing proxy (personal firewalls and such like)
with its settings configured to prevent onload (or sometimes onload
generated pop-ups, where the onload script errors while failing to
generate the pop-up), or on browsers like Mozilla which offer the user
options to refuse the execution of onload/onunload events.

But your invalid mark-up can be avoided by just moving the script
element to just before the closing BODY tag, when all of the elements on
the page will have been created in the DOM (if not maybe fully
configured, especially in terms of dimensions and positions/offsets).

Richard.
Jul 23 '05 #7
> You have edited my post here without indicating that you have done so,
moving my response to a direct statement of yours out of its original
context.
Sorry dude, my mistake.
But your invalid mark-up can be avoided by just moving the script
element to just before the closing BODY tag, when all of the elements on
the page will have been created in the DOM (if not maybe fully
configured, especially in terms of dimensions and positions/offsets).


Good suggestion.

I will try this technique. Nice thing about this technique is that the
javascript thread executed could use document.writes where if after
the closing body tag, you would have to use
document.body.innerHTML+=... (or other similar method)

To be honest, I cannot remember the exact browser that had the problem
with the onload method. It was either on my OSX box (ibook) with
Mozilla or on my win2k (dell) box with IE or Moz. The problem may
actually have been fixed but at the time it pissed me off so much that
I did bypass surgery on my pages and it's been working happily ever
since.

I realise that have been overly spoiled by working in a large but
contained corporate intranet world. Your points on building standards
based HTML is well taken.

Thanks for your time and input.

Tim
Jul 23 '05 #8

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

Similar topics

0
by: Deanne D'Souza | last post by:
We have just upgraded to Visual Studio .NET 2003, there seems to be an issue with the triggering of javascript on the onload event of a MODAL page. The page is opened as modal using the javascript...
2
by: Markus Sons | last post by:
Hello NG, I need some kind of triggering mechanism while capturing audio. I don't need to know the audio data itself, but I need to know, at which point in time the audio level climbs above a...
5
by: Emmanuel Papillon | last post by:
Hello. I've got a page with sound through a swf file, working with an animation with preloaded JPEG files (animated through use of setTimeout). I'm preloading the JPEG files through Javascript...
9
by: bmgz | last post by:
I need to execute a JavaScript function "onload". The only problem is I don not have access to the <body> tag as it is a part of the standard page-header include (a separate file). How could I have...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
0
by: gustavo_randich | last post by:
Hello, I'm looking for a DB2 workaround on a topic already solved in Oracle: the problem of mutating tables (which states that a trigger action cannot read the triggering table's data). Yes, I...
8
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the...
28
by: fred.haab | last post by:
Not having server side scripting, I've been doing this for "last modified" tags on my pages: <div class="modified"> <script type="Text/JavaScript"> <!-- document.write("This page was last...
6
by: pronerd | last post by:
Hi, I am trying to dynamically set an event handler across frames. I have no problems setting properties across frames doing something like parent.ToolMenuFrame.location.href =...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...

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.