generated pop-up window title not working

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rolandgust@gmail.com

    generated pop-up window title not working

    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,theFi le,windWidth,wi ndHeight,movWid th,movHeight)
    {
    videoWindow = window.open('ab out:blank', 'new',
    'width='+windWi dth+',height='+ windHeight+',st atus=no,toolbar =no,menubar=no, scrollbars=yes, resizable=yes')
    videoWindow.doc ument.write('<H TML>')
    videoWindow.doc ument.write('<H EAD>')
    videoWindow.doc ument.write('<T ITLE>'+theTitle +'</TITLE>')
    videoWindow.doc ument.write('</HEAD>')
    videoWindow.doc ument.write('<B ODY BGCOLOR="#12345 6"><CENTER>' )
    videoWindow.doc ument.write('<S CRIPT>top.docum ent.title =
    "'+theTitle +'"</SCRIPT>')
    videoWindow.doc ument.write('<T ABLE BORDER="0" CELLPADDING="8" ><TR><TD
    ALIGN="CENTER"> ')
    videoWindow.doc ument.write('<O BJECT
    CLASSID="clsid: 02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
    WIDTH="'+movWid th+'" HEIGHT="'+movHe ight+'"
    CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">< PARAM
    NAME="src" VALUE="'+theFil e+'.mov"><PARAM NAME="autoplay"
    VALUE="true"><P ARAM NAME="controlle r" VALUE="true"><E MBED
    SRC="'+theFile+ '.mov" WIDTH="'+movWid th+'" HEIGHT="'+movHe ight+'"
    AUTOPLAY="true" CONTROLLER="tru e"
    PLUGINSPAGE="ht tp://www.apple.com/quicktime/download/"></EMBED></OBJECT>')
    videoWindow.doc ument.write('</TD></TR></TABLE></CENTER></BODY></HTML>')
    }

  • Randy Webb

    #2
    Re: generated pop-up window title not working

    rolandgust@gmai l.com said the following on 11/28/2005 2:46 AM:[color=blue]
    > 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".[/color]

    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:
    <title>My Custom Window</title>
    set of tags.
    [color=blue]
    > Also, in FireFox, it acts as if the window never completely loads, the
    > progress bar stays at the bottom of the small window.[/color]

    <snip>
    [color=blue]
    > videoWindow.doc ument.write('</TD></TR></TABLE></CENTER></BODY></HTML>')[/color]

    videoWindow.doc ument.close() and the progress bar problem goes away.

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

    Comment

    • RobG

      #3
      Re: generated pop-up window title not working

      rolandgust@gmai l.com wrote:
      [...][color=blue]
      > Help!!!! :-)
      >
      > function
      > openVideoWindow (theTitle,theFi le,windWidth,wi ndHeight,movWid th,movHeight)
      > {
      > videoWindow = window.open('ab out:blank', 'new',
      > 'width='+windWi dth+',height='+ windHeight+',st atus=no,toolbar =no,menubar=no, scrollbars=yes, resizable=yes')
      > videoWindow.doc ument.write('<H TML>')
      > videoWindow.doc ument.write('<H EAD>')
      > videoWindow.doc ument.write('<T ITLE>'+theTitle +'</TITLE>')
      > videoWindow.doc ument.write('</HEAD>')
      > videoWindow.doc ument.write('<B ODY BGCOLOR="#12345 6"><CENTER>' )[/color]

      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.doc ument.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.doc ument.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.doc ument.write( HTMLstring );
      videoWindow.doc ument.close();

      [...]
      [color=blue]
      > videoWindow.doc ument.write('</TD></TR></TABLE></CENTER></BODY></HTML>')[/color]

      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).

      [...]


      --
      Rob

      Comment

      • rolandgust

        #4
        Re: generated pop-up window title not working

        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.

        Comment

        • rolandgust

          #5
          Re: generated pop-up window title not working

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

          Comment

          • rolandgust

            #6
            Re: generated pop-up window title not working

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

            function
            openVideoWindow (theTitle,theFi le,windWidth,wi ndHeight,movWid th,movHeight)
            {
            var HTMLstring =
            '<TITLE>'+theTi tle+'</TITLE>'
            + '<BODY BACKGROUND="gra phics/BACKorangeRedPa ttern.gif"
            BGCOLOR="#00000 0"><CENTER>'
            + '<TABLE BORDER="0" CELLPADDING="8" ><TR><TD ALIGN="CENTER"> '
            + '<OBJECT CLASSID="clsid: 02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
            WIDTH="'+movWid th+'" HEIGHT="'+movHe ight+'"
            CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">< PARAM
            NAME="src" VALUE="'+theFil e+'.mov"><PARAM NAME="autoplay"
            VALUE="true"><P ARAM NAME="controlle r" VALUE="true"><E MBED
            SRC="'+theFile+ '.mov" WIDTH="'+movWid th+'" HEIGHT="'+movHe ight+'"
            AUTOPLAY="true" CONTROLLER="tru e"
            PLUGINSPAGE="ht tp://www.apple.com/quicktime/download/"></EMBED></OBJECT>'
            + '</TD></TR></TABLE></CENTER></BODY>'

            videoWindow = window.open('', 'vidWnd',
            'width='+windWi dth+',height='+ windHeight+',st atus=yes,toolba r=no,menubar=no ,scrollbars=yes ,resizable=yes' )
            videoWindow.doc ument.write( HTMLstring )
            videoWindow.doc ument.close()
            }

            Comment

            • rolandgust

              #7
              Re: generated pop-up window title not working

              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.

              Comment

              • Randy Webb

                #8
                Re: generated pop-up window title not working

                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.c om, 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.
                [color=blue]
                > The whole point of this exercise is to eliminate the need for a
                > separate HTML file for every movie...[/color]

                Then eliminate the need. I told you how.
                [color=blue]
                > that's the way I had it and I got tired of the repetition of creating
                > that HTML file.[/color]

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

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

                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('my Page.html'+info Needed)

                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.

                --
                Randy
                comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
                Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


                Comment

                • rolandgust

                  #9
                  Re: generated pop-up window title not working

                  Randy Webb wrote:[color=blue]
                  > 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.c om, 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.[/color]

                  Thanks for enlightening me on that, I too appreciate good etiquette!
                  :-)
                  [color=blue][color=green]
                  > > that's the way I had it and I got tired of the repetition of creating
                  > > that HTML file.[/color]
                  >
                  > Then stop, read, and consider the options given to you.[/color]

                  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,theFi le,windWidth,wi ndHeight,movWid th,movHeight)
                  {
                  theParms =
                  'title='+theTit le+'&movie='+th eFile+'&width=' +movWidth+'&hei ght='+movHeight ;

                  videoWindow = window.open(' video_popup.htm l?'+theParms, 'vidWnd',
                  'width=' + windWidth + ',height=' + windHeight +
                  ',status=no,too lbar=no,menubar =no,scrollbars= no,resizable=no ')

                  return
                  }

                  And here is the video_popup.htm l 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.in dexOf(parm + "=");
                  if (startPos > -1) {
                  startPos = startPos + parm.length + 1;
                  var endPos = parms_passed.in dexOf("&",start Pos);
                  if (endPos == -1)
                  endPos = parms_passed.le ngth;
                  return unescape(parms_ passed.substrin g(startPos,endP os));
                  }
                  return '';
                  }

                  document.title = getParm('title' );

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

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

                  function getHeight() {
                  return '' + (parseInt(getPa rm('height'))+1 6);
                  }

                  </SCRIPT>

                  <BODY BACKGROUND="gra phics/BACKorangeRedPa ttern.gif" BGCOLOR="#23130 B">

                  <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="controlle r" VALUE="true">'
                  + '<EMBED SRC="' + getMovieName() + '.mov" WIDTH="' + getWidth() +
                  '" HEIGHT="'+getHe ight()+'" AUTOPLAY="true" '
                  + ' CONTROLLER="tru e"
                  PLUGINSPAGE="ht tp://www.apple.com/quicktime/download/">'
                  + '</EMBED></OBJECT>' );
                  </SCRIPT>
                  </TD></TR></TABLE>
                  </CENTER>

                  </BODY>
                  </HTML>

                  Comment

                  • rolandgust

                    #10
                    Re: generated pop-up window title not working


                    Lee wrote:[color=blue]
                    > rolandgust said:[color=green]
                    > >
                    > >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.[/color]
                    >
                    > I tested it in Firefox. What does "broke completely" mean?[/color]

                    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)

                    Comment

                    Working...