Open in New Window

Discussion in 'HTML & Website Design' started by billyvision, Jan 28, 2009.

  1. #1
    hi friends,

    I am new to web designing. I need your help. I want all links produced as a result these codes to open in new window. I dont know how to, please help. These codes produce latest forum posts.

    Regards,
    billyvision



    <table cellspacing="3" cellpadding="0" border="0" width="100%">
    <tr>
    	<td colspan="4"><b>My Forums Latest Posts</b></td>
    </tr>
    <tr>
    	<td width="55%">Post Title / Poster</td>
    	<td width="35%">Last Post</td>
    	<td width="5%" align="center">Replies</td>
    	<td width="5%" align="center">Views</td>
    </tr>
    $thread_list
    </table>
    Code (markup):

    <tr>
    	<td>
    		<div><a href="{$this->infernoexternal->ipsclass->base_url}showtopic=$thread[threadid]">$thread[title]</a></div>
    		<div><a href="{$this->infernoexternal->ipsclass->base_url}showuser=$thread[postuserid]" style="text-decoration: none;">$thread[postusername]</a></div>
    	</td>
    	<td>
    		<div>$thread[lastpost_date] $thread[lastpost_time]</div>
    		<div>
    			by
    			<a href="{$this->infernoexternal->ipsclass->base_url}showuser=$thread[last_userid]" style="text-decoration: none;">$thread[last_username]</a>
    			<a href="{$this->infernoexternal->ipsclass->base_url}showtopic=$thread[threadid]&view=getlastpost" style="text-decoration: none;">»</a>
    		</div>
    	</td>
    	<td align="center">$thread[replycount]</td>
    	<td align="center">$thread[views]</td>
    </tr>
    Code (markup):
    <tr>
    	<td colspan="4"><em>No threads to display</em></td>
    </tr>
    Code (markup):
     
    billyvision, Jan 28, 2009 IP
  2. phoonzang

    phoonzang Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try add
    TARGET = "_blank"
    Code (markup):
    to your
    A HREF
    Code (markup):
    links. Eg:
    <A HREF="newwindow.html" TARGET="_blank">a new window</A>
    HTML:
     
    phoonzang, Jan 28, 2009 IP
  3. ExtremeData

    ExtremeData Well-Known Member

    Messages:
    450
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    125
    #3
    You must add target="_blank" to your code.

    Use this code:
    
    <tr>
    	<td>
    		<div><a href="{$this->infernoexternal->ipsclass->base_url}showtopic=$thread[threadid]" target="_blank">$thread[title]</a></div>
    		<div><a href="{$this->infernoexternal->ipsclass->base_url}showuser=$thread[postuserid]" style="text-decoration: none;" target="_blank">$thread[postusername]</a></div>
    	</td>
    	<td>
    		<div>$thread[lastpost_date] $thread[lastpost_time]</div>
    		<div>
    			by
    			<a href="{$this->infernoexternal->ipsclass->base_url}showuser=$thread[last_userid]" style="text-decoration: none;" target="_blank">$thread[last_username]</a>
    			<a href="{$this->infernoexternal->ipsclass->base_url}showtopic=$thread[threadid]&view=getlastpost" style="text-decoration: none;" target="_blank">»</a>
    		</div>
    	</td>
    	<td align="center">$thread[replycount]</td>
    	<td align="center">$thread[views]</td>
    </tr>
    
    HTML:
    @phoonzang : Posted same time :)
     
    ExtremeData, Jan 28, 2009 IP
  4. thebambam

    thebambam Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I believe you do this <a href="" target="_blank">

    (target="_blank") <---

    THink thats what you want '-p
     
    thebambam, Jan 28, 2009 IP
  5. billyvision

    billyvision Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    let me try ~!
     
    billyvision, Jan 28, 2009 IP
  6. billyvision

    billyvision Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6


    It worked THANKS :) i appreciate it.
     
    billyvision, Jan 28, 2009 IP
  7. katendarcy

    katendarcy Peon

    Messages:
    115
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I don't mean to step on any toes or anything, but the issue with target="_blank" is that it doesn't validate in HTML/XHTML STRICT. So if you're using either of those DOCTYPES, it won't validate.

    I wasn't 100% sure about the HTML strict doctype, (because I've always used XHTML), so I looked it up quickly and it's the same. The target attribute can't be used unless you're using the HTML/XHTML Transitional DOCTYPE. So, if you want your site to validate you could either a) switch your DOCTYPE, or b) use JavaScript. (The downside obviously being that if someone has JS disabled it would open the link in the current window.) Basically, it would work like this:

    <a href="http://www.mysite.com" onclick="window.open('http://www.mysite.com');return false;">My Site</a>

    Alternatively, you could give your links a class, such as "forumPosts", and then have a JS function that loops through and does the above without needing to put it inline.

    Hope that wasn't too confusing! (And again, these changes are only necessary if you're using an HTML/XHTML STRICT DOCTYPE and want your site to validate.) : )


    ** Also, here's a link to an article I've read before and came across again when I was looking just now. He has an example of the type of function I mentioned above:
    http://www.thefutureoftheweb.com/blog/target-blank-xhtml11
     
    katendarcy, Jan 28, 2009 IP