473,657 Members | 2,537 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

force target=blank for all anchor tags on page

TS
is there a way to force all links on a page to open in a new browser window
without declaring them with a target=_blank attribute?

some kind of global thing? I thought i saw it in a stylesheet once, but
can't find it now.

thanks
Nov 19 '05 #1
5 4621
I think the base html tag should be able to do that.
Patrick

"TS" <ma**********@n ospam.nospam> wrote in message
news:OK******** ******@TK2MSFTN GP09.phx.gbl...
is there a way to force all links on a page to open in a new browser window without declaring them with a target=_blank attribute?

some kind of global thing? I thought i saw it in a stylesheet once, but
can't find it now.

thanks

Nov 19 '05 #2
you can try something like this on the client side:

<script type="text/javascript">
<!--

window.onload = function()
{
var links = document.links;
var length = links.length;

for(var i=0; i<length; i++)
{
var link = links[i];
if(externalLink (link.href))
{
link.target = "_blank";
}
}
}

function externalLink(hr ef)
{
return href.substring( 0,10) != "javascript ";
}

//-->
</script>

you don't want to open postback links in a new window, and probably not
links with "#" as the href either

cheers

Nov 19 '05 #3
Yup. Put this in the <head> tag:

<base target="_blank" >

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Patirck Ige" <na********@hot mail.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
I think the base html tag should be able to do that.
Patrick

"TS" <ma**********@n ospam.nospam> wrote in message
news:OK******** ******@TK2MSFTN GP09.phx.gbl...
is there a way to force all links on a page to open in a new browser

window
without declaring them with a target=_blank attribute?

some kind of global thing? I thought i saw it in a stylesheet once, but
can't find it now.

thanks


Nov 19 '05 #4
TS
thank you sir, that sounds like it!
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:eC******** ******@TK2MSFTN GP15.phx.gbl...
Yup. Put this in the <head> tag:

<base target="_blank" >

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Patirck Ige" <na********@hot mail.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
I think the base html tag should be able to do that.
Patrick

"TS" <ma**********@n ospam.nospam> wrote in message
news:OK******** ******@TK2MSFTN GP09.phx.gbl...
is there a way to force all links on a page to open in a new browser

window
without declaring them with a target=_blank attribute?

some kind of global thing? I thought i saw it in a stylesheet once, but
can't find it now.

thanks



Nov 19 '05 #5
to write this programatically :

<base runat="server" id="base1" />

....

void Page_Load()
{
base1.Attribute s["target"]="_blank";
}

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9282
by: Christophe Guillon | last post by:
Hello I would like to have a hypertext link which, when I click on it, leads to a web page where a certain word is highlighted. Depending on the link, the same target page would be displayed but with a different word highlighted. A bit like the search on google using the "cached" pages I have looked in several HTML tutorials, but I haven't found the answer...
2
315
by: Hazzard | last post by:
I am trying to figure out how to add an additional value to a querystring collection so that when I click on a datagrid cell, there will be a key to distinguish it from another column's functionality. I have Edit and Delete columns that each contain the ColumnID for the record I want to either edit, or delete. When I pull the item of the collection on the target page's page_load event, I will be able to either invoke a delete or an edit...
1
2984
by: VB Programmer | last post by:
I have a long html string I get from a rich text editor. How do I append "target='_blank' to all occurrances of "<A href=..." in the long html string easily? Is there an easy way, or do I have to go thru the string bit by bit and replace it using string functions? Thanks.
15
1932
by: dee | last post by:
Hi, I'm curious why MS decided to have Transfer hide the target page's url invisible? Any guesses ? Thanks. Dee.
8
12769
by: CJM | last post by:
What is the best way to force a page break when printing from a browser? A page in my application generates a series of tables which are usually less than will fit on a page of A4. Ideally I want to introduce a page break between each table when printing. I'm not sure what options I have available. I know there is some support in CSS but I'm no sure on the details or effectiveness. Thanks in advance...
1
1323
by: klynn | last post by:
I just built a .NET app where I put in the page an anchor such as: <a id="whatever" href="somesite" target="_blank">My anchor</a> for just one of my clients, when they click this anchor, ALL of their open windows associated with my .NET app close. Any idea why? I can't duplicate this on any other machine.
4
10104
Dököll
by: Dököll | last post by:
Hey Gang! I thought I had a good idea but then I realized JSF doesn't play that... I am trying to mimick what HTML can do in JSF when using target tags to related to inner HTML pages. In orther to get to a links going smoothly in JSF, on would do: <%@ page contentType="text/html" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
0
8303
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8723
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7316
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.