generated pop-up window title not working

R

rolandgust

I've written some code that creates a pop-up window to play back
QuickTime movies and then pushes HTML into that window so I don't have
to have a separate HTML file for every movie. The code works fine...
except for one thing, the silly window Title remains "Untitled". Also,
in FireFox, it acts as if the window never completely loads, the
progress bar stays at the bottom of the small window. Here's the
code... as you can see I set the title using the <TITLE> tag and then
again a last ditch effort using some JS.

Help!!!! :)

function
openVideoWindow(theTitle,theFile,windWidth,windHeight,movWidth,movHeight)
{
videoWindow = window.open('about:blank', 'new',
'width='+windWidth+',height='+windHeight+',status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes')
videoWindow.document.write('<HTML>')
videoWindow.document.write('<HEAD>')
videoWindow.document.write('<TITLE>'+theTitle+'</TITLE>')
videoWindow.document.write('</HEAD>')
videoWindow.document.write('<BODY BGCOLOR="#123456"><CENTER>')
videoWindow.document.write('<SCRIPT>top.document.title =
"'+theTitle+'"</SCRIPT>')
videoWindow.document.write('<TABLE BORDER="0" CELLPADDING="8"><TR><TD
ALIGN="CENTER">')
videoWindow.document.write('<OBJECT
CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
WIDTH="'+movWidth+'" HEIGHT="'+movHeight+'"
CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab"><PARAM
NAME="src" VALUE="'+theFile+'.mov"><PARAM NAME="autoplay"
VALUE="true"><PARAM NAME="controller" VALUE="true"><EMBED
SRC="'+theFile+'.mov" WIDTH="'+movWidth+'" HEIGHT="'+movHeight+'"
AUTOPLAY="true" CONTROLLER="true"
PLUGINSPAGE="http://www.apple.com/quicktime/download/"></EMBED></OBJECT>')
videoWindow.document.write('</TD></TR></TABLE></CENTER></BODY></HTML>')
}
 
R

Randy Webb

(e-mail address removed) said the following on 11/28/2005 2:46 AM:
I've written some code that creates a pop-up window to play back
QuickTime movies and then pushes HTML into that window so I don't have
to have a separate HTML file for every movie. The code works fine...
except for one thing, the silly window Title remains "Untitled".

A better solution would be to re-use a static HTML file and let it load
whatever file you want to load into the OBJECT tag. You can also have
that static HTML page set its document.title by script. But not all
browsers allow that to happen that way. Simply use a static file with a:
Also, in FireFox, it acts as if the window never completely loads, the
progress bar stays at the bottom of the small window.

videoWindow.document.write('</TD></TR></TABLE></CENTER></BODY></HTML>')

videoWindow.document.close() and the progress bar problem goes away.
 
R

RobG

Help!!!! :)

function
openVideoWindow(theTitle,theFile,windWidth,windHeight,movWidth,movHeight)
{
videoWindow = window.open('about:blank', 'new',
'width='+windWidth+',height='+windHeight+',status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes')
videoWindow.document.write('<HTML>')
videoWindow.document.write('<HEAD>')
videoWindow.document.write('<TITLE>'+theTitle+'</TITLE>')
videoWindow.document.write('</HEAD>')
videoWindow.document.write('<BODY BGCOLOR="#123456"><CENTER>')

In addition to what Randy said, it is better to write all the HTML in
one go rather than multiple document.writes:

videoWindow = window.open(...);
videoWindow.document.write(
'<title>' + theTitle + '</title>',
'<TABLE BORDER="0" CELLPADDING="8">',
'<TR><TD> ALIGN="CENTER">',
'<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"',
' WIDTH="' + movWidth + '" HEIGHT="' + movHeight + '"',
...
'</TD></TR></TABLE></CENTER>'
);
videoWindow.document.close();


You can also put all the HTML into a single string then write that.

var HTMLstring =
'<title>' + theTitle + '</title>'
+ '<TABLE BORDER="0" CELLPADDING="8">'
+ '<TR><TD> ALIGN="CENTER">'
+ '<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"'
+ ' WIDTH="' + movWidth + '" HEIGHT="' + movHeight + '"'
...
+ '</TD></TR></TABLE></CENTER>'

videoWindow.document.write( HTMLstring );
videoWindow.document.close();

[...]
videoWindow.document.write('</TD></TR></TABLE></CENTER></BODY></HTML>')

You don't have opening html or body tags, so best not to have closing
ones (html and body tags are optional in HTML 4).

[...]
 
R

rolandgust

The whole point of this exercise is to eliminate the need for a
separate HTML file for every movie... that's the way I had it and I got
tired of the repetition of creating that HTML file. I *thought* that
this should be possible in javascript and it seems to be except for
this silly problem with the title. However, if I can't get this
javascript to work properly I will create a CGI in Perl instead.
 
R

rolandgust

I don't have opening tags?? But I do, is something wrong with them?? I
don't see the problem...
 
R

rolandgust

I changed the code as follows... but the title still does not change
from "Untitled" in Safari or "about:Firefox" in Firefox. The close() at
the end fixes the progress bar issue in Firefox, however! So thanks for
that! :)

function
openVideoWindow(theTitle,theFile,windWidth,windHeight,movWidth,movHeight)
{
var HTMLstring =
'<TITLE>'+theTitle+'</TITLE>'
+ '<BODY BACKGROUND="graphics/BACKorangeRedPattern.gif"
BGCOLOR="#000000"><CENTER>'
+ '<TABLE BORDER="0" CELLPADDING="8"><TR><TD ALIGN="CENTER">'
+ '<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
WIDTH="'+movWidth+'" HEIGHT="'+movHeight+'"
CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab"><PARAM
NAME="src" VALUE="'+theFile+'.mov"><PARAM NAME="autoplay"
VALUE="true"><PARAM NAME="controller" VALUE="true"><EMBED
SRC="'+theFile+'.mov" WIDTH="'+movWidth+'" HEIGHT="'+movHeight+'"
AUTOPLAY="true" CONTROLLER="true"
PLUGINSPAGE="http://www.apple.com/quicktime/download/"></EMBED></OBJECT>'
+ '</TD></TR></TABLE></CENTER></BODY>'

videoWindow = window.open('', 'vidWnd',
'width='+windWidth+',height='+windHeight+',status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=yes')
videoWindow.document.write( HTMLstring )
videoWindow.document.close()
}
 
L

Lee

rolandgust said:
I changed the code as follows... but the title still does not change
from "Untitled" in Safari or "about:Firefox" in Firefox. The close() at
the end fixes the progress bar issue in Firefox, however! So thanks for
that! :)

function
openVideoWindow(theTitle,theFile,windWidth,windHeight,movWidth,movHeight)
{
var HTMLstring =
videoWindow = window.open('', 'vidWnd',
'width='+windWidth+',height='+windHeight+',status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=yes')
videoWindow.document.write( HTMLstring )
videoWindow.document.close()
}

This is one of the few cases where the "javascript:" pseudo-protocol
is useful:

function openVideoWindow(theTitle,theFile,
windWidth,windHeight,
movWidth,movHeight)
{
globalHTMLstring =
'<TITLE>'+theTitle+'</TITLE>'
+ '<BODY BACKGROUND="graphics/BACKorangeRedPattern.gif"'
+ ' BGCOLOR="#000000"><CENTER>'
+ '<TABLE BORDER="0" CELLPADDING="8"><TR><TD ALIGN="CENTER">'
+ '<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"'
+ ' WIDTH="'+movWidth+'" HEIGHT="'+movHeight
+ '"CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab"'
+ '><PARAM NAME="src" VALUE="'+theFile
+ '.mov"><PARAM NAME="autoplay" VALUE="true"><PARAM NAME='
+ '"controller" VALUE="true"><EMBED SRC="'+theFile
+ '.mov" WIDTH="'+movWidth+'" HEIGHT="'+movHeight
+ '"AUTOPLAY="true" CONTROLLER="true" PLUGINSPAGE='
+ '"http://www.apple.com/quicktime/download/"></EMBED></OBJECT>'
+ '</TD></TR></TABLE></CENTER></BODY>';

videoWindow = window.open('javascript:eek:pener.globalHTMLstring',
'vidWnd',
'width='+windWidth+',height='
+windHeight+',status,scrollbars,resizable');
}
</script>
 
R

rolandgust

Thanks, but the title remains Untitled in Safari and it breaks Firefox
completely... window pops open but movie doesn't play. You would think
this would be simple... all I want to do is change the title of the
silly window!! :) I'm getting very very close to ditching this and
making a CGI which I *know* will work. I was hoping to avoid another
place for code, it is nice and neat to just have it all in a .js file.
 
R

Randy Webb

rolandgust said the following on 11/28/2005 11:11 AM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
The whole point of this exercise is to eliminate the need for a
separate HTML file for every movie...

Then eliminate the need. I told you how.
that's the way I had it and I got tired of the repetition of creating
that HTML file.

Then stop, read, and consider the options given to you.
I *thought* that this should be possible in javascript and it seems
to be except for this silly problem with the title.

It is very possible and the "silly problem" becomes moot.
However, if I can't get this javascript to work properly I will create
a CGI in Perl instead.

You would be basically creating a CGI script in Javascript is all.

In your main page, you pass a parameter to the page in window.open:

window.open('myPage.html'+infoNeeded)

And then in myPage.html you read the querystring, retrieve the info you
need, and then dynamically generate the page. The exact same way it
would be done if you were using a Perl CGI script.

The infoNeeded variable could contain the new title, you simply
document.write the title tags.
It would also hold the name of the file to open in that new window, then
you simply create your object tags with JS using that data.

All with one file.
 
R

rolandgust

Randy said:
rolandgust said the following on 11/28/2005 11:11 AM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

Thanks for enlightening me on that, I too appreciate good etiquette!
:)
Then stop, read, and consider the options given to you.

I apologize for my hasty response to your initial answer, I thought my
question had been misunderstood... when I was the one not paying
attention!! :) I ended up doing exactly what you recommended, namely
treating javascript as a CGI sort of mechanism... I had to pass 4
parameters to the viewer HTML code and then parse that out. (I've
included the code below in case it is of help to anyone out there!)

So thanks so much for your help! It works great!

Here is the calling code:

function
openVideoWindow(theTitle,theFile,windWidth,windHeight,movWidth,movHeight)
{
theParms =
'title='+theTitle+'&movie='+theFile+'&width='+movWidth+'&height='+movHeight;

videoWindow = window.open(' video_popup.html?'+theParms, 'vidWnd',
'width=' + windWidth + ',height=' + windHeight +
',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no')

return
}

And here is the video_popup.html file:

<HTML>
<HEAD>
<TITLE>Loading...</TITLE>
</HEAD>

<SCRIPT>

var parms_passed = location.search.substring(1);

// getParm adapted from http://www.irt.org/articles/js063/
function getParm(parm) {
// returns value of parm from parms_passed
var startPos = parms_passed.indexOf(parm + "=");
if (startPos > -1) {
startPos = startPos + parm.length + 1;
var endPos = parms_passed.indexOf("&",startPos);
if (endPos == -1)
endPos = parms_passed.length;
return unescape(parms_passed.substring(startPos,endPos));
}
return '';
}

document.title = getParm('title');

function getMovieName() {
return getParm('movie');
}

function getWidth() {
return getParm('width');
}

function getHeight() {
return '' + (parseInt(getParm('height'))+16);
}

</SCRIPT>

<BODY BACKGROUND="graphics/BACKorangeRedPattern.gif" BGCOLOR="#23130B">

<CENTER>
<TABLE BORDER="0" CELLPADDING="8">
<TR><TD ALIGN="CENTER">
<SCRIPT>
document.write('<OBJECT
CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" '
+ 'WIDTH="' + getWidth() + '" '
+ 'HEIGHT="' + getHeight() + '"
CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">'
+ '<PARAM NAME="src" VALUE="' + getMovieName() + '">'
+ '<PARAM NAME="autoplay" VALUE="true">'
+ '<PARAM NAME="controller" VALUE="true">'
+ '<EMBED SRC="' + getMovieName() + '.mov" WIDTH="' + getWidth() +
'" HEIGHT="'+getHeight()+'" AUTOPLAY="true" '
+ ' CONTROLLER="true"
PLUGINSPAGE="http://www.apple.com/quicktime/download/">'
+ '</EMBED></OBJECT>' );
</SCRIPT>
</TD></TR></TABLE>
</CENTER>

</BODY>
</HTML>
 
L

Lee

rolandgust said:
Thanks, but the title remains Untitled in Safari and it breaks Firefox
completely... window pops open but movie doesn't play. You would think
this would be simple... all I want to do is change the title of the
silly window!! :) I'm getting very very close to ditching this and
making a CGI which I *know* will work. I was hoping to avoid another
place for code, it is nice and neat to just have it all in a .js file.

I tested it in Firefox. What does "broke completely" mean?
 
R

rolandgust

Lee said:
rolandgust said:

I tested it in Firefox. What does "broke completely" mean?

The movie didn't play. However, I've got it all working using a
separate HTML file, passing 4 parameters to that page after opening it.
(See my other replies)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top