Results 1 to 3 of 3

Thread: Pop-up window title?

  1. #1
    Join Date
    Jan 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Pop-up window title?

    Hi,

    I am using the following script to open a pop-up window:

    Code:
    <head>
    <script>
    <!-- Begin
    function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=270,height=110,left = 595,top = 325');");
    }
    // End -->
    </script>
    </head>
    
    <body>
    <a href="javascript:popUp('popup.html')"><b>Open Window</b></a>
    </body>
    Is it possible to add a title to the page in the browser? And if so, how?

    For example, here:



    Thanks,

    Des.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Ugh.
    Code:
    <script>
    The type attribute is required.
    Code:
    <!-- Begin
    This has been unnecessary for a long time: while there are some browsers left that don't do Javascript, they all at least know enough to ignore it.
    Code:
    day = new Date();
    day hasn't been declared, so you're unnecessarily making it global; the same applies to id. It also seems kind of pointless to store the window if you're not going to do anything with it.
    Code:
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=270,height=110,left = 595,top = 325');");
    eval() is very ugly and very rarely required. Here, for example, one would use an array. If, for some reason that doesn't apply here, you really wished to create individual global variables, you could access them as window[nameOfVariable]; for example,
    Code:
    window["page" + id] = window.open( ... );
    Code:
    <script type="text/javascript">
    var pages = [];
    function popUp(URL) {
      var opts =
        "toolbar=0," +
        "scrollbars=0," +
        "statusbar=0," +
        "menubar=0," +
        "resizable=0," +
        "width=270," +
        "height=110," +
        "left=595," +
        "top=325";
    
      pages.push(
        window.open(URL,
          "win" + pages.length,
          opts
        )
      );
    }
    </script>
    You can change the title of the window with document.title, at least if the page is on the same domain.
    Code:
    var pages = [];
    function popUp(url, title) {
      var opts =
        "toolbar=0," +
        "scrollbars=0," +
        "statusbar=0," +
        "menubar=0," +
        "resizable=0," +
        "width=270," +
        "height=110," +
        "left=595," +
        "top=325";
    
      pages.push(
        window.open(url,
          "win" + pages.length,
          opts
        )
      );
      pages[pages.length - 1].document.title = title;
    }
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks very much for your reply and the information.
    My domain name is actually being directed to a folder on my server, so perhaps it's not possible.

    Thanks again for your help.

    Des.

    Sorry, it works fine. I made a silly mistake linking to it.
    Last edited by derek barnstorm; 01-24-2007 at 11:04 PM. Reason: I made a silly mistake

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •