HTML Help
HTML Help Central . com

» Online Users: 85

0 members and 85 guests
No Members online
Most users ever online was 695, 02-16-2011 at 07:01 AM.

» Site Navigation

 > FAQ

» Domains For Sale

Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2013
    Posts
    1

    Trying to get HTML to open up a NEW TAB or Browser window when Item Selected on Web-Page

    Hi I am working on my Golf website and was trying to have my code set-up when you click on an item such as By-laws open a new browser window etc instead of just taking the current browser to the new location..


    I was messing around with On Click but cannot seem to get the syntax correct:

    Here is my original code:

    <a class="navigation style30" href="http:A Web Site ">
    <font color="#0000FF" style="font-size: 21pt">Post your Score</font></a></p>

    I am trying to get this to open up in a NEW Separate Browser window or a NEW tab etc..

    Can anyone Help..

    Thanks..
    Last edited by CBSTEK; 11-15-2013 at 04:47 PM.

  2. #2
    Join Date
    Sep 2007
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    369
    Hi there CBSTEK,

    and a warm welcome to these forums.

    Here is a basic pop-up script...

    Code:
    
    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    <meta charset="utf-8">
    
    <title>basic pop-up</title>
    
    
    <style>
    #pys {
        font-size:28px;
        color:#00f;
     }
    #pys:hover {
        color:#f00;
     }
    </style>
    
    <script>
    (function() {
       'use strict';
    
       var w=800;   /* editable window width */
       var h=400;   /* editable window height */
    
    
       var mywindow;
       var l=(screen.width-w)/2;
       var t=(screen.height-h)/2;
       var features='width='+w+', height='+h+', top='+t+' ,left='+l+' ,scrollbars=1';
    
    function init(){
    
       var anc=document.getElementsByTagName('a');
       var c=anc.length;
    
    while(--c>-1) {
    if(anc[c].className.match('popup')){
       anc[c].onclick=function(){
    if(mywindow) {
       mywindow.close();
     }
       mywindow=window.open(this.href,'',features);
       mywindow.focus();
       return false;
        }
       }
      } 
     }
       window.addEventListener?
       window.addEventListener('load',init,false):
       window.attachEvent('onload',init);
    })();
    </script>
    
    </head>
    <body>
    
    <div>
     <a class="popup" id="pys" href="http://www.htmlhelpcentral.com/messageboard/forum.php">Post your Score</a>
    </div>
    
    </body>
    </html>
    Last edited by coothead; 11-18-2013 at 03:04 AM.
    http://www.htmlhelpcentral.com/messageboard/image.php?type=sigpic&userid=8698&dateline=1189772  724

  3. #3
    Join Date
    Apr 2013
    Location
    Bangalore
    Posts
    54
    Hello, there is in-built attribute of anchor tag called "target". You can use that to open the link in new window/tab.
    example : <a href="YOUR_LINK" target="_blank">
    This will open your link in new tab.

Similar Threads

  1. Using variables from parent page in child page with window.open()
    By ohnori in forum Javascript / AJAX / VBScript
    Replies: 3
    Last Post: 01-30-2013, 01:41 PM
  2. removing the selected item
    By shadiadi in forum PHP
    Replies: 2
    Last Post: 05-02-2009, 06:53 AM
  3. HELP!? : open.window useed in a window opened by open.window NOT WORKING?!!
    By Effector 13 in forum Javascript / AJAX / VBScript
    Replies: 4
    Last Post: 08-07-2003, 10:22 PM
  4. Open new browser window w/o tool bars & menu bar
    By Jim Chapman in forum Javascript / AJAX / VBScript
    Replies: 3
    Last Post: 10-01-2002, 11:39 PM
  5. Open page in new window from framed page
    By Greatgraddage in forum HTML / XHTML / XML
    Replies: 3
    Last Post: 05-02-2001, 12:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBadvanced CMPS v4.1.1