473,396 Members | 1,754 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.

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.document.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="javascript: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","width=600,height=300,res izable");
console.document.open("text/plain");
MHUAHAHA = litany;
}

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

console.document.write(MHUAHAHA);
litany = MHUAHAHA;
}

</script>
<h1>ALL YOUR BASE ARE BELONG TO US!</h1>
<form>
<input type=button value="HELP!!!" onclick="javascript:msg(this.value)"/>
</form>
</body>
</html>
--
NOTE: In my address everything before the period is backwards.
Jul 23 '05 #1
3 2065
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.document.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="javascript: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","width=600,height=300,res izable");
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.document.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.document.write(MHUAHAHA);
litany = MHUAHAHA;
}

</script>
<h1>ALL YOUR BASE ARE BELONG TO US!</h1>
<form>
<input type=button value="HELP!!!" onclick="javascript:msg(this.value)"/>
</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*****@agricoreunited.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.document.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="javascript: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","width=600,height=300,res izable");

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.document.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.document.write(MHUAHAHA);
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="javascript:msg(this.value)"/>
</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*****@agricoreunited.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
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): ---------- ...
5
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...
2
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...
1
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...
1
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...
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...
1
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...
4
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...
1
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...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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...
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.