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 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)
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
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
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
now, after trying what you said Andy, it reloads the original window,
and gives the error "newwindow has no propertys" at line 31
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
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.
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.
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
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.
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
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
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; undervar 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)
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.
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
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
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
by: infobahn |
last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
|
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...
|
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...
| |
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 & \...
|
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...
|
by: albert.neu |
last post by:
Hello!
What is the difference between "library parts" of C99 and "language
parts" of C99.
see...
|
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...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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: 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...
|
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...
| |
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |