473,508 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Null or not an object - Not displaying document.write(...) in child modal window .

I'm trying to figure out this script doesn't display any text in the
child window and why I'm getting the null or not an object error.
It's taken directly from the Javascript and DHTML cookbook (not listed
in the book errata on o'reilly website). Initially I get an error
"window.dialogArguments.yourName" is null or not an object. Then I
fill out the field on the form, press the button and the child window
does display but there is no text inside the child window.

Questions: Should I be declaring an object that isn't currently
declared like "window"? or is "window" a built in object that doesn't
need declaring? do I need to assign the dialogDoc.html or "result" to
"document" somehow? It looks like they have me putting a value in
"result" then never actually using "result"... confused... Using ie
6.02800...Suggestions? gj
<html>
<head>
<title> Launch a Modal Dialog</title>
<script type="text/javascript">

function openDialog(form){
var result = window.showModalDialog("dialogDoc.html", form,
"dialogWidth:300px; dialogHeight:201px; center:yes");
}
</script>
</head>
<body>
<h1>Internet Explorer Modal Dialog Window</h1>
<hr />
<form name="sample" action="#" onsubmit="return false">
Enter your name for the dialog box:<input name="yourName" type="text"
/>
<input type="button" value="Send to Dialog"
onclick="openDialog(this.form)" />
</form>
</body>
</html>

<html>
<head>
<title>Modal Dialog</title>
</head>
<body>
<script type="text/javascript">
document.write("Greetings from " +
window.dialogArguments.yourName.value + "!");
</script>
</body>
</html>
Jul 23 '05 #1
3 6620
Jc
The "this.form" on the onclick event of the button looks kind of
out-of-place to me, I typically use a different way to reference
objects. Here's something else to try instead of "this.form":

document.forms("sample")

Here's a reference for the above code:

http://msdn.microsoft.com/library/de...ence_entry.asp

Click the reference link at the top of the page to see the full DHTML
Reference.

Jul 23 '05 #2
On 6 Oct 2004 20:44:46 -0700, Jc <go****@weinrichs.com> wrote:
The "this.form" on the onclick event of the button looks kind of
out-of-place to me, I typically use a different way to reference
objects. [...]
In intrinsic events, the this operator refers to the element. So with

<input ... onchange="this....">

the object reference yielded by the this operator refers to that INPUT
element. Furthermore, all form controls contain a property, form, which
refers to the containing form, if one exists.
document.forms("sample")


You should use square brackets to subscript collections. The use of
parentheses appears to be a Microsoft invention that isn't supported by
all browsers. It certainly fails in the Mozilla Suite and Firefox.

document.forms['formName']

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3
Jc wrote:
The "this.form" on the onclick event of the button looks kind of
out-of-place to me,
A function assigned as the event handler for an element is executed as a
method of that element and as a result the - this - keyword will refer
to that element. The - form - property of form controls is a reference
to the containing form (or null if the control is outside of the form).
The property was implemented in the earliest browsers that implemented
forms and has been formalised in the W3C HTML DOM standard, making -
this.form - the most reliable (and portable) way of passing on an
anonymous reference to the containing form from a form control event
handler fucntion.
I typically use a different way to reference
objects. Here's something else to try instead of "this.form":

document.forms("sample")

<snip>

Parenthesising "sample" turns a property accessor into a method call. It
is a Microsoftism that, while supported by some other browsers, is not
universally supported. It is also contrary to the W3C HTML DOM
specification, where the ECMAScript bindings explicitly dictate the
actions of dot/bracket notation accessors, but do not specify that the -
forms - collection should act as a function.

A standard bracket notation property accessor:-

document.forms["sample"]

- Works 100% on IE, and every other browser implementing
-document.forms - collection. It is the cross-browser formulation to
use in this context (the Microsoft parenthesised version should never be
used, least it becomes a bed habit that makes cross-browser scripting
seem harder than it really is).

Richard.
Jul 23 '05 #4

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

Similar topics

2
1320
by: Charles Law | last post by:
Does anyone know how to create a new document window in VB.NET (or any other language)? I have Googled extensively but to no avail. I am creating a VS add-in, and want to include my own...
6
9933
by: Ramanand.K | last post by:
var docCal function hello() { winCal= window.open("",null,"toolbar=0,status=0,menubar=0,fullscreen=no,width=195,he ight=245,resizable=0,top="+cnTop+",left="+cnLeft); docCal =...
0
1834
by: satish jupalli via .NET 247 | last post by:
Hi all, I have a word Add-in from which i will open a word new document. For this document I want to remove maximize, resize option. I'm able to remove the resize option using stsyle &=...
8
2877
by: tshad | last post by:
I am using Andy Smiths Dialog windows, which work really well. My only problem is I am trying to make the Dialogs Modal. Someone mentioned putting <base target="_self"> into the head section...
1
1949
by: Bill Borg | last post by:
Hello all, Simple chat app, where the site owner has a master window with all requests for chat, status of each room, etc., and child windows for each separate chat in which the owner is...
3
4629
by: tigrrgrr42 | last post by:
I am working(vb.net03and05) with word documents stored in a sql db and I am currently bringing them from a byte array into a temp file to pop into word and make word do its thing as a com object. ...
4
9484
by: mpreston | last post by:
I'm following the example from the MSDN library on how to create modal dialog boxes in C#, but something isn't working properly. If I create a modal dialog box and show it using ShowDialog(), the...
3
1092
by: Simon Tamman | last post by:
In VS 2005 they've replaced (in the main document window) the handly lefty/righty arrows with a hideous drop down list. Anyone know how to change it back to VS 2003 style? Simon
0
1013
by: dattaforit | last post by:
Hello Friends, I am using VC++ 2005. I have an application for C#. In this application i want to display a modal dialog box or a modal form in a thread. I have on thread running and in that...
0
7225
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
7123
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
7326
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,...
1
7046
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
7498
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
5627
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,...
0
4707
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...
0
3194
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...
0
418
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...

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.