473,378 Members | 1,099 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,378 software developers and data experts.

example on how to change href's text needed....

Mel
can someone post a simple javascript to change the text of the <href> for me
?

thanks
Jul 23 '05 #1
5 25958
Lee
Mel said:

can someone post a simple javascript to change the text of the <href> for me
?


What is "the text of the <href>" ?
The visible text of the link, or the href attribute value?

Jul 23 '05 #2
Mel
< a href=xxx>ABCD</a>

ABCD is what i need to change :-)

thanks

"Lee" <RE**************@cox.net> wrote in message
news:d1*********@drn.newsguy.com...
Mel said:

can someone post a simple javascript to change the text of the <href> for me?


What is "the text of the <href>" ?
The visible text of the link, or the href attribute value?

Jul 23 '05 #3
Lee
Mel said:

< a href=xxx>ABCD</a>

ABCD is what i need to change :-)

thanks

"Lee" <RE**************@cox.net> wrote in message
news:d1*********@drn.newsguy.com...
Mel said:
>
>can someone post a simple javascript to change the text of the <href> forme >?


What is "the text of the <href>" ?
The visible text of the link, or the href attribute value?

<a id="Link1" href="xxx">ABCD</a>

<script type="text/javascript">
document.getElementById("Link1").innerHTML="WXYZ";
</script>

Jul 23 '05 #4
Lee wrote:
Mel said:
< a href=xxx>ABCD</a>

ABCD is what i need to change :-)

thanks

"Lee" <RE**************@cox.net> wrote in message
news:d1*********@drn.newsguy.com...
Mel said:

can someone post a simple javascript to change the text of the <href> for

[...]

<a id="Link1" href="xxx">ABCD</a>

<script type="text/javascript">
document.getElementById("Link1").innerHTML="WXYZ";
</script>


A couple of other alternatives:

Really simple:

<a id="Link1" href="#" onclick="
this.innerHTML = 'WXYZ';">ABCD</a>

With a function, passing a reference:

<a id="Link1" href="#" onclick="modText(this);">ABCD</a>

<script type="text/javascript">
function modText(ele){
ele.innerHTML="WXYZ";
}
</script>

As above, but using DOM rather than the non-standard innerHTML:

<a id="Link1" href="#" onclick="modText(this);">ABCD</a>

<script type="text/javascript">
function modText(ele){
ele.childNodes[0].nodeValue = "WXYZ";
}
</script>

--
Rob
Jul 23 '05 #5
Mel wrote:
can someone post a simple javascript to change the text of the <href> for me ?

thanks


<html>
<head>
<style type="text/css">

a {display: block; font: 500% tahoma; color: crimson;}

</style>
<script type="text/javascript">

function setLinkText(sLink_id, sText)
{
var el;
if (document.getElementById
&& (el = document.getElementById(sLink_id))
|| document.all
&& (el = document.all[sLink_id]))
{
while (el.hasChildNodes())
el.removeChild(el.lastChild);
el.appendChild(document.createTextNode(sText));
}
}

onload = function()
{
setTimeout("setLinkText('foo1', 'zippity');", 2000);
setTimeout("setLinkText('foo2', 'doo');", 3000);
setTimeout("setLinkText('foo3', 'dah !');", 3500);
}

</script>
</head>
<body>
<a id="foo1" href="#">z</a>
<a id="foo2" href="#">d</a>
<a id="foo3" href="#">d</a>
</body>
</html>

Jul 23 '05 #6

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

Similar topics

9
by: Peter | last post by:
Hi at all, how can I do to make a css file to change automatically the text size of the text that is into a table relatively the screen size? I.E. if the screen is 800 x I want the text...
17
by: Christopher Nelson | last post by:
I have a menu tree made up of anchors inside list items in a multi-level list that includes HTML like: <ul id='xx'> <li><a href='conf.cgi' class='menu' target='main' title='Configure stuff'...
3
by: Charlie Dison | last post by:
Hi there, How can I change the caption of a button in a grid at runtime? I seem to be able to change the header text in the column where the button appears but not the button caption. Thanks in...
2
by: Simon | last post by:
Dear reader, Is it possible to change the text of a label in a form on the event "By open". In the event some VBA code will change the label text.
3
by: ajaspersonal | last post by:
"i want to change font_style (hyper link<a href...>text</a>) normal to italics.when load a page" this is my problem but that label included in one 'USERCONTROL' This user controls may...
0
by: write2jagdeep | last post by:
i Want to change color of text item when got focus in forms builber d2k and revert that color when lost focus. Pls anser it urgently.
2
by: Rinaldo | last post by:
How to change the button text of a openfiledialog in to my own custum test?
1
by: Amit00 | last post by:
Hi, I have an ascx file with a gridview, and I need to change the header text of the gridview's column in the code-behind. Something like that: foreach (DataControlField col in GridView1.Columns)...
13
by: BobLewiston | last post by:
Can anybody tell me how to change WinForm controls' text color programatically? I have no problem finding the fields to assign colors to, but the compiler doesn't recognize any color I mention,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.