473,549 Members | 2,639 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.dialogA rguments.yourNa me" 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...Sugge stions? gj
<html>
<head>
<title> Launch a Modal Dialog</title>
<script type="text/javascript">

function openDialog(form ){
var result = window.showModa lDialog("dialog Doc.html", form,
"dialogWidth:30 0px; dialogHeight:20 1px; center:yes");
}
</script>
</head>
<body>
<h1>Internet Explorer Modal Dialog Window</h1>
<hr />
<form name="sample" action="#" onsubmit="retur n false">
Enter your name for the dialog box:<input name="yourName" type="text"
/>
<input type="button" value="Send to Dialog"
onclick="openDi alog(this.form) " />
</form>
</body>
</html>

<html>
<head>
<title>Modal Dialog</title>
</head>
<body>
<script type="text/javascript">
document.write( "Greetings from " +
window.dialogAr guments.yourNam e.value + "!");
</script>
</body>
</html>
Jul 23 '05 #1
3 6627
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****@weinric hs.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
1322
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 document window to present some information. Any pointers greatly received.
6
9937
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 = winCal.document; RenderCal(); }
0
1837
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 &= (~(WS_THICKFRAME)); And applying this style to That window using user32.dll library imported function. Similarly I tried to remove maximize but its not...
8
2889
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 of the modal window to make it work. I tried putting it both pages just to see if it would work and it doesn't seem to work. Does anyone know how...
1
1950
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 engaged. When the owner closes one of his child windows, I want to update the master window. I understand "reasonably" well how to go about this. The...
3
4644
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. Is it possible to go straight from a byte array to document in word instead of a temp file? Also is there a way to change the save behaviour to...
4
9485
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 main form behind the dialog box is still enabled and can operate normally. If I use MessageBox.Show() to show a message box, the main form is...
3
1093
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
1015
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 thread i want to display a modal dialog box or a modal form. Can anybody please help me out. Thanks
0
7462
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7975
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...
1
7492
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...
0
7823
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6059
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...
0
5101
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...
0
3491
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1957
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
777
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...

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.