473,503 Members | 1,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

" " is not defined

Could any one give me an explenation of this error? I get it every
once in a while, and it really is a pain. currently the code that I'm
working with goes like this

<script>
<!--
var newwindow;
function moviepopup(url)
{

newwindow=window.open(url,'moviewindow','height=28 0,width=340,toolbar=no,menubar=no,locatio=no,statu s=yes,left=435,top=25');
if (window.focus) {newwindow.focus()}
}

function checkwindow()
{
if (!moviewindow.closed && moviewindow.location) {
moviepopup(url);
}
else
{
return false;
}
}
-->
</script>

that goes in the <HEAD>
and then it is called multiple times from the body like this

<div align="center"><font face="Verdana, Arial, Helvetica,
sans-serif" size="1"><font color="#993333"><strong>Sundance
/ Cabin</strong><br>
<a onClick="checkwindow()"
target="moviewindow"
href="javascript:moviepopup('movies/05-01.mov');"><img
src="images/movies/05-01.gif" alt="" name="" width="100" height="100"
border="0"></a></font> </font><br>
<font color="#993333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">Click to Play</font><br>
<font face="Verdana, Arial, Helvetica,
sans-serif" size="1"><font face="Verdana, Arial, Helvetica, sans-serif"
size="1"><font color="#993333"> </font></font></font></div>

Now, if you can't tell what the effect I'm going for, its like this.
When you click on a picture, a sized windows appears with a movie
inside it. it loads and plays. If/When another movie is clicked on the
original page, I want the second movie to reload in the "moviewindow" I
was advised to write checkwindow() by a javascrpt guru through the
email, but it is hard to keep a conversation with him. can anyone help
me with this. thanks

-Evan

Sep 26 '05 #1
21 3320
Evan Sussman wrote on 26 sep 2005 in comp.lang.javascript:
Could any one give me an explenation of this error? I get it every
once in a while, and it really is a pain. currently the code that I'm
working with goes like this

<script>
missing type='text/javascript'
<!--
don't use this anymore since 2000
var newwindow;
function moviepopup(url)
{

newwindow=window.open(url,'moviewindow','height=28 0,width=340,toolbar=n
o,menubar=no,locatio=no,status=yes,left=435,top=25 ');
if (window.focus) {newwindow.focus()}
perhaps sometimes the newwindow is not ready when applying the focus.
why should window not have the focus, as you just clicked in it?

I suppose the code should be [and be testing for that]:

if (newwindow) {newwindow.focus()}

}

function checkwindow()
{
if (!moviewindow.closed && moviewindow.location) {
moviepopup(url);
Here add:

return true
}
else
else not realy necessary
{
return false;
}
}
-->
as above
</script>

that goes in the <HEAD>
and then it is called multiple times from the body like this

<div align="center"><font face="Verdana, Arial, Helvetica,
sans-serif" size="1"><font color="#993333"><strong>Sundance
/ Cabin</strong><br>
Please do not show us unnecessary code, it distracts.
<a onClick="checkwindow()"
target="moviewindow"
This target declaration is never used by your javascript, skip it.
href="javascript:moviepopup('movies/05-01.mov');">

The onclick needs a return:

onClick="return checkwindow()"

but I would prefer not to use the href="javascript:.. at all, try:

<a onClick="if (checkwindow())moviepopup('movies/05-01.mov');"
href='#'>

Or still better, move the moviepopup() into the checkwindow() function

<img src="images/movies/05-01.gif" alt="" name="" width="100" height="100"
border="0"></a></font> </font><br>
<font color="#993333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">Click to Play</font><br>
<font face="Verdana, Arial, Helvetica,
sans-serif" size="1"><font face="Verdana, Arial, Helvetica,
sans-serif" size="1"><font color="#993333">
</font></font></font></div>
skip most of this showing it to us.
Go from here
[..]


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Sep 26 '05 #2
thanks, will try.

Sep 26 '05 #3
ok, when I changed
<a onClick="checkwindow()" target="moviewindow"
href="javascript:moviepopup('movies/05-01.mov');">
to
<a onClick="if (checkwindow())moviepopup('movies/05-01.mov');" >href="javascript:moviepopup('movies/05-01.mov');">
It worked, but it still returned "moviewindow is not defined" on line
31

then I tried it with
href="#"


and it wouldn't load, still returned "movie is not defined" on line 31

so somehow, the href to the javascript is still needing to play a part
in the script. anyone have any suggestions. thanks Evertjan, as your
last post was very helpful.

-Evan

Sep 26 '05 #4
when I remove the href altogether, it still gives the same error as the
href="#" I guess that was a stupid attempt.
lol

-evan
still testing

Sep 26 '05 #5
Evan Sussman wrote:
ok, when I changed

<a onClick="checkwindow()" target="moviewindow"
href="javascript:moviepopup('movies/05-01.mov');">

to

<a onClick="if (checkwindow())moviepopup('movies/05-01.mov');" >href="javascript:moviepopup('movies/05-01.mov');">

It worked, but it still returned "moviewindow is not defined" on line
31


And it isn't!

You assign window.open's result to newwindow and have newwindow as a
global variable. You should therefore use:
if (!newwindow.closed && newwindow.location) {
moviepopup(url);
}

There is probably another way to get to the moviewindow object (as you
assigned it that name), but not the way you're doing it.

Cheers,
Andy
Sep 26 '05 #6
now, after trying what you said Andy, it reloads the original window,
and gives the error "newwindow has no propertys" at line 31

Sep 26 '05 #7
Evan Sussman wrote:
now, after trying what you said Andy, it reloads the original window,
and gives the error "newwindow has no propertys" at line 31


Is the page available online anywhere?

Anyway, try changing it to:

if (newwindow && !newwindow.closed && newwindow.location) {
moviepopup(url);
}

This should check to see if newwindow is set.

Cheers,
Andy
Sep 26 '05 #8
yeah, go to http://www.whitmoreacademy.com/movies.php
you will have to login with
UN=admin
PW=chilcotin

Sep 26 '05 #9
after changing that, all it does is reload this time no errors. I guess
we're making progress, well now we can't target an error. Now we gotta
get the window to open, and the original window not to reload.

Sep 26 '05 #10
just realized I had a typo in the properties area, no change though.
also, the reason that the page is reloading, is that Firefox must
handle the href="#" as link to self. when I load the page in Safari,
there is no link and nothing happens when I click on the picture.

Sep 26 '05 #11
Evan Sussman wrote:
after changing that, all it does is reload this time no errors. I guess
we're making progress, well now we can't target an error. Now we gotta
get the window to open, and the original window not to reload.


Sorry, I think I didn't actually listen to what you wanted it to do.
And still without reading that (but now I seem to have a better
understanding), how about the following

var newwindow;
function moviepopup(url)
{
if (newwindow) {
newwindow.location = url;
}
else {
newwindow=window.open(url,'moviewindow','height=28 0,width=340,toolbar=no,menubar=no,locatio=no,statu s=yes,left=435,top=25');
}
if (newwindow) {newwindow.focus()}
}

function checkwindow()
{
moviepopup(url);
if (!newwindow) {
return false;
}
}

I don't actually think you need the checkwindow function. Try that and
see if it does what you think. If not send me an email with your
MSN/ICQ/Jabber details and I'll try to help you over IM.

Cheers,
Andy
Sep 26 '05 #12
Lee
Evan Sussman said:

Could any one give me an explenation of this error? I get it every
once in a while, and it really is a pain. currently the code that I'm
working with goes like this

<script>
<!--
var newwindow;
function moviepopup(url)
{

newwindow=window.open(url,'moviewindow','height=2 80,width=340,toolbar=no,menubar=no,locatio=no,stat us=yes,left=435,top=25');
if (window.focus) {newwindow.focus()}
}

function checkwindow()
{
if (!moviewindow.closed && moviewindow.location) {

The first time you run checkwindow(), the window will not exist, and
so moviewindow will not be defined. The function should also check
to see if the window identifier is defined. You should actually be
using "newwindow", in place of "moviewindow", as the identifier.

Sep 26 '05 #13
right now I have to go take care of something, I will get back here as
soon as I am done, thansk for the help, and I will see about an IM, i
don't have one right now.

-evan

Sep 26 '05 #14
just tried changing
newwindow=window.open(url,'moviewindow','height=2 80,width=340,toolbar=no,menubar=no,locatio=no,stat us=yes,left=435,top=25');
to
moviewindow=window.open(url,'moviewindow','height =280,width=340,toolbar=no,menubar=no,locatio=no,st atus=yes,left=435,top=25');
and adding
var moviewindow; undervar newwindow;
I am still returned "movie window has no properties" at line 32, why,
when I give it properties here
moviewindow=window.open(url,'moviewindow','height =280,width=340,toolbar=no,menubar=no,locatio=no,st atus=yes,left=435,top=25');
do I have to give the
var moviewindow;


properties, if so how?

-Evan

thanks guys

Sep 26 '05 #15
Evan Sussman wrote on 26 sep 2005 in comp.lang.javascript:
just tried changing
newwindow=window.open(url,'moviewindow','height= 280,width=340,toolbar=n
o,menubar=no,locatio=no,status=yes,left=435,top= 25');
to
moviewindow=window.open(url,'moviewindow','heigh t=280,width=340,toolbar
=no,menubar=no,locatio=no,status=yes,left=435,to p=25');


and adding
var moviewindow;

under
var newwindow;


I am still returned "movie window has no properties" at line 32, why,


We don't know about line numbers
when I give it properties here
moviewindow=window.open(url,'moviewindow','heigh t=280,width=340,toolbar
=no,menubar=no,locatio=no,status=yes,left=435,to p=25');


do I have to give the
var moviewindow;


properties, if so how?


In general, and I said so earlier, it takes time to make a new window,
so while the window is being set up, it is not defined in the propperties
sense. Defining the variable that wil be it's pointer, won't help you.
This will give an error:

document.title = 'Original'
w = window.open('','myWindow','')
w.document.title = 'theWindow'

but this will work:

document.title = 'Original'
w = window.open('','myWindow','')
setTimeout("w.document.title = 'theWindow'",1000)

IE6 tested

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Sep 26 '05 #16
Evan Sussman wrote:
yeah, go to http://www.whitmoreacademy.com/movies.php
you will have to login with
UN=admin
PW=chilcotin
Hello Evan,

This is what you currently have on your site:
<script type="text/javascript">
var newwindow;
var moviewindow;
You don't appear to be using the variable moviewindow anywhere.

function moviepopup(url)
{
if (newwindow)
{
newwindow.loacation=url;
location is misspelled.
}
else
{
newwindow=window.open(url,'moviewindow','height=28 0,width=340,toolbar=no,menubar=no,location=no,stat us=yes,left=435,top=25');
if (newwindow)
{
newwindow.focus()
It's always a good practice to include a semi-colon at the end of every
statement.
}
}
Don't forget to include a closing } for your function.

function checkwindow()
{
if (newwindow && !newwindow.closed && newwindow.location)
{
moviepopup(url);
You're using the variable url here, however, where is the value coming
from?
return true
Add semi-colon at the end.
}
else
{
return false;
}
}
</script>
This is what you have done for your anchor links:
<a onClick="checkwindow()" target="moviewindow" href="javascript:moviepopup('movies/canada/1.mov');"></a>


Personally, I would prefer you would do it this way instead, and it
degrades nicely:

<a href = "movies/canada/1.mov" target = "moviewindow" onClick =
"return checkwindow()">...</a>

In fact, you can combine both of your functions to produce this
instead:

<script type="text/javascript">
var newwindow = null;

function showMovie(url)
{
if (newwindow && !newwindow.closed)
{
newwindow.location = url;
newwindow.focus();

return false;
}
else
{
newwindow =
window.open(url,'moviewindow','height=280,width=34 0,toolbar=no,menubar=no,location=no,status=yes,lef t=435,top=25');

return false;
}

return true;
}
</script>

Then in your anchor tag all you need to is the following:

<a href = "movies/canada/1.mov" target = "moviewindow" onClick =
"return showMovie('movies/canada/1.mov')">...</a>

Hope this helps.

Sep 26 '05 #17
ASM
Evertjan. a écrit :
Evan Sussman wrote on 26 sep 2005 in comp.lang.javascript:

just tried changing

[...]
In general, and I said so earlier,
[...]
but this will work:

document.title = 'Original'
w = window.open('','myWindow','')
setTimeout("w.document.title = 'theWindow'",1000)

this would have too

document.title = 'Original'
w = window.open('','myWindow','')
w.onload = function() { w.document.title = 'theWindow'}

--
Stephane Moriaux et son [moins] vieux Mac
Sep 26 '05 #18
Thanks, this does help. It works. Now I gotta change all of them, and I
need to examine what your script is doinginstead, thanks again

_Evan

Sep 26 '05 #19
also, I was expecting the script to pull url here...

function checkwindow()
{
if (newwindow && !newwindow.closed && newwindow.location)
{
moviepopup(url);

from
<a onClick="checkwindow()" target="moviewindow" href="javascript:moviepopup('movies/canada/1.mov');"></a>

moviepopup('movies/canada/1.mov');"

there,

from your reaction to it, I would guess that doesn't work. Please
explain how it does work, cause from the tutorial that I got the script
from, it seemed like thats what they wanted me to do.

-Evan

Sep 26 '05 #20
Hey, I just though of one more thing.
I have a movie on the page, that is larger then the other ones. Is
there any way to define the width and height from the html tag, or do I
have to write a different script??
Thanks for all the help

-Evan

Sep 26 '05 #21
also, I am now testing in other browsers then firefox, (I really
should've done this before) and safari doesn't reload "moviewindow"
once it is already open. could some other people test this for me with
their browsers? the effect I'm going for is
1) your at the movies page
2)when you click a picture of a movie, a sized window appears and loads
the movie in it.
3) when you click a different movie on the original page, with the
moviewindow still open, it reloads in the moviewindow.

I can't test IE, because it runs like crap on my computer.

thanks

-Evan

Sep 26 '05 #22

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

Similar topics

9
13086
by: bill | last post by:
Forget the exact definition of difference between, #include <foo.h> and #include "bar.h" Normally foo.h is a standard header file, so it's path is not defined in compiler option, but I...
8
3358
by: TTroy | last post by:
I have a few questions about "scope" and "visibility," which seem like two different things. To me "visibility" of the name of a function or object is the actual code that can use it in an...
188
17193
by: infobahn | last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
49
14430
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On...
3
11988
by: nan | last post by:
Hi All, I am trying to connect the Database which is installed in AS400 using DB2 Client Version 8 in Windows box. First i created the Catalog, then when i selected the connection type...
43
2680
by: markryde | last post by:
Hello, I saw in some open source projects a use of "!!" in "C" code; for example: in some header file #define event_pending(v) \ (!!(v)->vcpu_info->evtchn_upcall_pending & \...
9
10695
by: Klaus Johannes Rusch | last post by:
IE7 returns "unknown" instead of "undefined" when querying the type of an unknown property of an object, for example document.write(typeof window.missingproperty); Has "unknown" been defined...
3
1690
by: albert.neu | last post by:
Hello! What is the difference between "library parts" of C99 and "language parts" of C99. see...
30
4637
by: kj | last post by:
My book (Flanagan's JavaScript: The Definitive Guide, 5th ed.) implies on page 111 that the following two constructs are equivalent: ( x.constructor == Foo ) and ( x instanceof Foo ) The...
4
9829
by: FullBandwidth | last post by:
I have been perusing various blogs and MSDN pages discussing the use of event properties and the EventHandlerList class. I don't believe there's anything special about the EventHandlerList class in...
0
7202
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
7086
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
7280
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
7330
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
5578
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,...
1
5014
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...
0
4672
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
3167
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...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.