By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,598 Members | 1,894 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,598 IT Pros & Developers. It's quick & easy.

" " is not defined

P: n/a
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
Share this Question
Share on Google+
21 Replies


P: n/a
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

P: n/a
thanks, will try.

Sep 26 '05 #3

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
yeah, go to http://www.whitmoreacademy.com/movies.php
you will have to login with
UN=admin
PW=chilcotin

Sep 26 '05 #9

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.