473,703 Members | 4,167 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mozilla onload: "no properties"; IE OK

kj


This problem is driving me nuts. The code at the end of this post
below works fine with IE, but fails with Mozilla. You can see it
in action at

http://tinyurl.com/2jvo3

With Mozilla 1.4 and 1.6, the function msg works fine if it's
installed as an onclick handler for the button, but fails as an
onload handler for the page. The error is "console has no properties",
and is triggered by the line.

console.documen t.open("text/plain");

The code works fine on all versions of IE I've tested it on.

Is there an error in my code (that IE is letting slide), or is this
a bug in Mozilla? If the latter, is there a workaround?

Thanks!

kj

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">

<head><title>JA VASCRIPT STUMPER</title></head>
<body onload="javascr ipt:msg('PLEASE HELP ME!!!') // bombs on NS, moz">

<script type="text/javascript">

// Adapted from Flanagan's "JavaScript : The Definitive Guide", 3rd Ed.

var console = null;
var litany = "";
var times = 0;

function msg(s) {
var MHUAHAHA = "";
if ((console == null) || (console.closed )) {
console = window.open("", "console","widt h=600,height=30 0,resizable");
console.documen t.open("text/plain");
MHUAHAHA = litany;
}

MHUAHAHA += (++times > 1
? "I've told you " + times + " times already!!! "
: "") + "RESISTANCE IS FUTILE!\n";

console.documen t.write(MHUAHAH A);
litany = MHUAHAHA;
}

</script>
<h1>ALL YOUR BASE ARE BELONG TO US!</h1>
<form>
<input type=button value="HELP!!!" onclick="javasc ript:msg(this.v alue)"/>
</form>
</body>
</html>
--
NOTE: In my address everything before the period is backwards.
Jul 23 '05 #1
3 2087
kj wrote:
This problem is driving me nuts. The code at the end of this post
below works fine with IE, but fails with Mozilla. You can see it
in action at

http://tinyurl.com/2jvo3

With Mozilla 1.4 and 1.6, the function msg works fine if it's
installed as an onclick handler for the button, but fails as an
onload handler for the page. The error is "console has no properties",
and is triggered by the line.

console.documen t.open("text/plain");

The code works fine on all versions of IE I've tested it on.

Is there an error in my code (that IE is letting slide), or is this
a bug in Mozilla? If the latter, is there a workaround?

Thanks!

kj

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">

<head><title>JA VASCRIPT STUMPER</title></head>

<body onload="javascr ipt:msg('PLEASE HELP ME!!!') // bombs on NS, moz">

<script type="text/javascript">

// Adapted from Flanagan's "JavaScript : The Definitive Guide", 3rd Ed.

var console = null;
var litany = "";
var times = 0;

function msg(s) {
var MHUAHAHA = "";
if ((console == null) || (console.closed )) {
console = window.open("", "console","widt h=600,height=30 0,resizable");
This is an asynchronous method call. window.open() is called, opens a new
window and returns a reference to the newly created window. There is no
guarantee, none, that when the method window.open() returns, there is a valid
document in the newly created window.
console.documen t.open("text/plain");
You immediately attempt to access the document property of the newly opened
window, as stated above, there is no guarantee that a document property of a
newly opened window is available to do _anything_ with immediately following
a window.open() call.
MHUAHAHA = litany;
}

MHUAHAHA += (++times > 1
? "I've told you " + times + " times already!!! "
: "") + "RESISTANCE IS FUTILE!\n";

console.documen t.write(MHUAHAH A);
litany = MHUAHAHA;
}

</script>
<h1>ALL YOUR BASE ARE BELONG TO US!</h1>
<form>
<input type=button value="HELP!!!" onclick="javasc ript:msg(this.v alue)"/>
</form>
</body>
</html>


The "fix" or "workaround " is to actually load a .html file into the newly
created window that contains something like:

<body onload="if (opener && opener.callBack ) opener.callBack ();">

callBack(); would be a function in the opener window that writes whatever
content you want to the newly created window (or does whatever else you would
like done). In this way, you can be assured that the only time the code to
write content to the new window runs is once the new window is opened and
ready for it's content.

--
| Grant Wagner <gw*****@agrico reunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #2
Lee
kj said:



This problem is driving me nuts. The code at the end of this post
below works fine with IE, but fails with Mozilla. You can see it
in action at

http://tinyurl.com/2jvo3

With Mozilla 1.4 and 1.6, the function msg works fine if it's
installed as an onclick handler for the button, but fails as an
onload handler for the page. The error is "console has no properties",
and is triggered by the line.


Mozilla is blocking popups. A window.open() call from
the onload handler is considered to be a popup that
should be blocked. You can change that setting.

Jul 23 '05 #3
DU
Grant Wagner wrote:
kj wrote:

This problem is driving me nuts. The code at the end of this post
below works fine with IE, but fails with Mozilla. You can see it
in action at

http://tinyurl.com/2jvo3

With Mozilla 1.4 and 1.6, the function msg works fine if it's
installed as an onclick handler for the button, but fails as an
onload handler for the page. The error is "console has no properties",
and is triggered by the line.

console.documen t.open("text/plain");

The code works fine on all versions of IE I've tested it on.

Is there an error in my code (that IE is letting slide), or is this
a bug in Mozilla? If the latter, is there a workaround?

Thanks!

kj

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">

<head><title> JAVASCRIPT STUMPER</title></head>

<body onload="javascr ipt:msg('PLEASE HELP ME!!!') // bombs on NS, moz">

<script type="text/javascript">

// Adapted from Flanagan's "JavaScript : The Definitive Guide", 3rd Ed.

var console = null;
var litany = "";
var times = 0;

function msg(s) {
var MHUAHAHA = "";
if ((console == null) || (console.closed )) {
console = window.open("", "console","widt h=600,height=30 0,resizable");

This is an asynchronous method call. window.open() is called, opens a new
window and returns a reference to the newly created window. There is no
guarantee, none, that when the method window.open() returns, there is a valid
document in the newly created window.

console.documen t.open("text/plain");

You immediately attempt to access the document property of the newly opened
window, as stated above, there is no guarantee that a document property of a
newly opened window is available to do _anything_ with immediately following
a window.open() call.


Correct. He also calls, uses a parameter which is no longer valid in DOM
2 HTML. open() takes no parameters.

http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-72161170

MHUAHAHA = litany;
}

MHUAHAHA += (++times > 1
? "I've told you " + times + " times already!!! "
: "") + "RESISTANCE IS FUTILE!\n";

console.documen t.write(MHUAHAH A);
litany = MHUAHAHA;
He never closes the document stream: so the browser waits (Mozilla-based
browsers are more sensitive to this) for more info and keep the stream
open. It gives the user the impression that the document never ends
loading, the progress icon never stops turning, progressmeter is always
active, as if the browser is always waiting for more info.

"close
Closes a document stream opened by open() and forces rendering."

http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-98948567
}

</script>
<h1>ALL YOUR BASE ARE BELONG TO US!</h1>
<form>
<input type=button value="HELP!!!" onclick="javasc ript:msg(this.v alue)"/>
</form>
</body>
</html>

The "fix" or "workaround " is to actually load a .html file into the newly
created window that contains something like:

<body onload="if (opener && opener.callBack ) opener.callBack ();">

callBack(); would be a function in the opener window that writes whatever
content you want to the newly created window (or does whatever else you would
like done). In this way, you can be assured that the only time the code to
write content to the new window runs is once the new window is opened and
ready for it's content.


I entirely agree with your explanations and solution. I think this
problem is so often encountered and is not well documented that it
should be addressed by this newsgroup FAQ.
This happened to me once and I couldn't find any documentation on this
issue.

DU
--
| Grant Wagner <gw*****@agrico reunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html

Jul 23 '05 #4

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

Similar topics

7
5845
by: GfxGuy | last post by:
I've seen this problem posted a million times, but I've read through all of them and can't figure out what I'm doing wrong. Simple example (this is the whole file, no editing): ---------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>
5
1743
by: Brad | last post by:
All samples related to this see to come short of being 'truly' dynamic. For instance, after creating all the code to load/save a properties value, you turn around and save it to one you KNOW exists: foo.Height = (my loaded value)... I am trying to load and set the property on the fly - without necessarily knowing what it is. Imagine a 100 name/value pairs in a file (config, res, txt, whatever). I want to load and set those on the fly,...
2
5348
by: edgarjang | last post by:
In JavaScript, I can hide menu bar ( ex) <html> <SCRIPT LANGUAGE="JavaScript"> function Test() { var win = window.open("test2.html","sale","menubar=no,scrollbars=no,width=780,height=5 40,top=0,left=0") window.opener = "OPENER_IS_NOT_NULL";
1
1503
by: rajesh | last post by:
Hi all; For me also the same error "crossobj has no properties" is occuring while running in mozilla browser for the same calender.Plz help me to solve this problem with coding as soon as possible. Thanks u in advance by N.Jayaram
1
2298
by: dasayu | last post by:
Hi, I have a custom object called gridWidget. I am consistantly getting an error in FireFox when I click on an href, which calls a function defined on the object. The generated link looks similar to: javascript:gridWidget.editColumn(3, 3, 'PDDSectionForm', 'pdd_link', ..) The above works fine in IE.
28
2264
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 modified: " + document.lastModified); --> </script>
1
2772
by: pbd22 | last post by:
hi. for some reason i am not able to navigate the dom. i keep getting the 'no properties' error but i think i am doing everything right. this is an XML response from an AJAX call. The ajax method to call the server code looks like this. i am passing a cookie as a parameter:
4
2642
by: dr1ft3r | last post by:
Hey guys, I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an iframe's src property. Being that IE does not follow standard and considers an id, name, etc as a qualifying identifier for the document.getElementById object, I double checked to make sure that there's only one instance of id = "servif" and I never use...
1
2668
by: luispunchy | last post by:
I have an accordion style dropdown list/sublist menu (functions similar to the "today on WebMD video" widget found on http://www.webmd.com/) - it will allow users to click on a headline (from the main list) to open up the full listing (sublist) below that headline. My JavaScript is almost but not quite working as needed. It also serves up an error that an object "has no properties". The particular error message and line of code it refers to:...
0
9125
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
9018
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
7876
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
6595
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
5923
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
4434
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2463
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2070
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.