473,549 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make hyperlink invisible?

Hi there,

I would like to make an hyperlink invisible, or disabled, with a click. The
hyperlink opens a new window (target = _blank) and once the new window is
shown, I don't want the hyperlink to be active anymore.

How can I do this?

Thanks in advance,

-Benton

Apr 1 '06 #1
3 8897
<script type="text/javascript">
function disappear(ancho r)
{
window.open( anchor.href );
anchor.style.di splay = 'none';
return false;
}
</script>

Then for every anchor <a href="somepage. html" onclick="return
disappear( this );">click me!</a>

Bonus points if you can get all the anchors to do this when the page
loads WITHOUT adding the onclick to all the links

Apr 1 '06 #2
bobzimuta said the following on 3/31/2006 9:00 PM:

Please quote what you are replying to.

If you want to post a followup via groups.google.c om, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
<URL: http://www.safalra.com/special/googlegroupsreply/ >
<script type="text/javascript">
function disappear(ancho r)
{
window.open( anchor.href );
And if the user is using a popup blocker that disables window.open?
Symantec comes to mind first.
anchor.style.di splay = 'none';
return false;
}
</script>

Then for every anchor <a href="somepage. html" onclick="return
disappear( this );">click me!</a>
<a href="somepage. html" onclick="this.s tyle.display = 'none';">Look Ma!
No function</a>
Bonus points if you can get all the anchors to do this when the page
loads WITHOUT adding the onclick to all the links


Triple bonus points to you if you can learn to quote and post properly.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 1 '06 #3
bobzimuta wrote:
<script type="text/javascript">
function disappear(ancho r)
{
window.open( anchor.href );
anchor.style.di splay = 'none';
return false;
}
</script>

Then for every anchor <a href="somepage. html" onclick="return
disappear( this );">click me!</a>

Bonus points if you can get all the anchors to do this when the page
loads WITHOUT adding the onclick to all the links


Perfectly straightforward :

window.onload=f unction()
{
for(var i=0; i<document.link s.length; i++)
document.links[i].onclick=new Function(
"document.l inks["+i+"].style.display= "+
"'none';window. open(document.l inks["+i+"]);"+
"return false");
}

Setting display to 'none' could upset the layout of the page, so
perhaps visibility='hid den' would be better for this application.
To leave the link visible or re-styled, one can generate a 'clicked'
flag for each link and inspect it before opening the window:

window.onload=f unction()
{
for(var i=0; i<document.link s.length; i++)
document.links[i].onclick=new Function(
"var lnk=document.li nks["+i+"];"+
"if(typeof lnk.wasClicked= ='undefined')"+
"{window.open(l nk);lnk.style.v isibility="+
"'hidden';lnk.w asClicked=true; }return false;");
}

--
S.C.

Apr 1 '06 #4

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

Similar topics

40
10769
by: Brian Jorgenson | last post by:
On my web page, I have a few hyperlinks with target frame of _blank. The hyperlink brings up a second window, but everytime I click on thie hperlink, it keeps bringing up a new window and not defaulting the the first active window. How do I make a hyperlink point to the active window? I don not want the hyperlink to default to the same page. I...
3
6814
by: Susan Bricker | last post by:
Greetings. I have three forms that are open at the same time. They are related and cascading. The first form (frmEventAdd) is the anchor. Each event can have many Trials. The second form is frmTrialInfo. Each Trial can have three Classes. The third form is frmClassInfo. These forms are used for update and adding new records. The user...
2
1697
by: acko bogicevic | last post by:
Hi On my aspx page i have hyperlink: <A id="lnkEndUser" onclick="window.open('AddHelpLink.aspx','cal','width=250,height=300,left =270,top=180') href="javascript:;"><IMG src="Slike\usr.gif" border="0"></A> When the page is load fist time i want this link to be invisible. But when i click on btnUpdate i would like this link to be visible....
4
4379
by: James P. | last post by:
Hello there, I have an asp hyperlink in a template page. In my user control page - code behind page that uses the template, I'd like to turn this link invisible in certain case. Is it possible? This is my hyperlink: <asp:HyperLink id="hplShoppingCart" runat="server" Font-Size="Larger" Font-Names="Arial"...
3
2152
by: Richard | last post by:
After printing a userlist to a Datagrid i want some names not to be shown. I want to know how i can make a entire datagrid row invisible. I suspect its something with the OnItemDatabound but i am kinda stuck there. but this is basicly what i want. if Username = "Deleted_User" then 'make entire table row invisible. End if
4
3136
by: Mark Rae | last post by:
Hi, I have an <asp:PlaceHolder control on a page in an ASP.NET 1.1 app, as follows: <td nowrap><asp:PlaceHolder ID="phClientWebsite" Runat=server>&nbsp;</asp:PlaceHolder></td> Server-side, I'm running the following code:
4
2462
by: NH | last post by:
Hi, I just cannot get this to work. I want to make a cell editable in a datagrid only if the value of another cell is something specific. I am able to capture the value of the other cell via the ItemDataBound event of the datagrid e.g. If e.Item.Cells(8).Text = "2" Then 'Make the textbox defined in my edititemtemplate read only of...
7
7013
by: Nader | last post by:
It's easy to make the last row in a datagrid (filled with a table) invisible: datagridObject.Rows.Visible = false BUT if 'i' is not the last row then things go wrong. I even tried: for (int i = datagridObject.Rows.Count - 1; i >= 0; i-- ) {
20
1964
by: Prisoner at War | last post by:
Hi, People, Is it possible to have an "empty" or "dummy" <a href***without*** the browser jumping back up the page?? I have a hyperlink that doesn't point to another document, but is used to call forth a modal window onClick (or is there another way, without text or image links, of calling forth JavaScript on user activity??). I would...
0
7548
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7472
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...
0
7986
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...
0
7832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5114
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...
0
3499
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1083
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
786
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...

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.