Results 1 to 2 of 2

Thread: New Window

  1. #1
    Join Date
    Dec 2004
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default New Window

    How can I modify following code so the link will open in a new window which width and height will be specified by me in code ?
    Code:
    <script type="text/javascript">
    <!--
    
    // New/No new PM button in menu
    
    // Image to show there are new private messages
    var newPM = "http://home.ripway.com/2005-5/316598/addfriend.gif";
    
    // Image to show there are no new private messages
    var noPM = "http://home.ripway.com/2005-5/316598/house.gif";
    
    var pmLink = document.createElement("a");
    var pmImg = document.createElement("img");
    var pmCell = document.getElementsByTagName("td").item(2).innerHTML;
    
    pmLink.href = "http://viktorix.hyperboards3.com/index.cgi?action=pm_view";
    pmImg.border = "0";
    
    if(pmCell.match(/you have <.+?>, (\d+) /i)){
        switch(RegExp.$1){
           case "0" :
              pmImg.src = noPM;
              pmImg.title = "You have no new private messages.";
              break;
           case "1" :
              pmImg.src = newPM;
              pmImg.title = "You have 1 new private message.";
              break;
           default :
              pmImg.src = newPM;
              pmImg.title = "You have " + RegExp.$1 + " new private messages.";
        }
    pmLink.appendChild(pmImg);
        document.getElementsByTagName("td").item(5).appendChild(pmLink);
    }
    
    //-->
    </script>
    I want this link http://viktorix.hyperboards3.com/ind...action=pm_view to be open in a new window.
    Thanks!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Replace this:
    Code:
    pmLink.href = "http://viktorix.hyperboards3.com/index.cgi?action=pm_view";
    with this:
    Code:
    pmLink.href = "javascript:window.open('http://viktorix.hyperboards3.com/index.cgi?action=pm_view','newWin','width=500, height=300')";
    Change 500 and 300 to whatever you want. For more information on window.open() check out:

    http://www.dynamicdrive.com/dynamicindex8/popwin.htm

    also Google:

    window.open javascript
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •