473,395 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 8887
<script type="text/javascript">
function disappear(anchor)
{
window.open( anchor.href );
anchor.style.display = '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.com, 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(anchor)
{
window.open( anchor.href );
And if the user is using a popup blocker that disables window.open?
Symantec comes to mind first.
anchor.style.display = '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.style.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.javascript 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(anchor)
{
window.open( anchor.href );
anchor.style.display = '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=function()
{
for(var i=0; i<document.links.length; i++)
document.links[i].onclick=new Function(
"document.links["+i+"].style.display="+
"'none';window.open(document.links["+i+"]);"+
"return false");
}

Setting display to 'none' could upset the layout of the page, so
perhaps visibility='hidden' 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=function()
{
for(var i=0; i<document.links.length; i++)
document.links[i].onclick=new Function(
"var lnk=document.links["+i+"];"+
"if(typeof lnk.wasClicked=='undefined')"+
"{window.open(lnk);lnk.style.visibility="+
"'hidden';lnk.wasClicked=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
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...
3
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...
2
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"...
4
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...
3
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...
4
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,...
4
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...
7
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...
20
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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,...

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.