473,463 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Truncate hyperlink automatically

Hello I want to show some 10 of my Hyperlinks in a box in right side of my page
My problem is hyperlink is so long, so i want to show dot(...) at the end of the line. I dont want to extend the hyperlink to the second link so please any one help me with the code
Jun 9 '07 #1
3 1565
My guess would be to write








<a href="your URL">your URL untill it gets too long and then you put ...</a>
Jun 9 '07 #2
gits
5,390 Expert Mod 4TB
hi ...

have a look at the following example and play with it ;) (in case you want to create your list dynamically)

[HTML]<script>
function create_link_list() {
var url_list = {
1: 'verylongurltodisplay.html',
2: 'http://www.google.de',
3: 'veryverylongurltodisplay.html'
};

var link_container = document.getElementById('link_list');

for (var i in url_list) {
var url = url_list[i];

var line_break = document.createElement('br');
var anchor_element = document.createElement('a');
anchor_element.href = url;

var url_txt = url;

if (url_txt.length > 20) {
url_txt = url.match(/(.{17})/)[1] + '...';
}
anchor_element.innerText = url_txt;

link_container.appendChild(anchor_element);
link_container.appendChild(line_break);
}
}
</script>

<body onload="create_link_list()">
<div id="link_list"></div>
</body>[/HTML]

hope this helps, and

kind regards ...
Jun 9 '07 #3
acoder
16,027 Expert Mod 8TB
Changed thread title.
Jun 11 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Nel | last post by:
I am trying to write a content management section for a web site. I have managed so far to use htmlarea to give users a basic, but user friendly interface by which to edit the page content. ...
1
by: New MSSQL DBA | last post by:
I have recently been assigned to take over several MSSQL environments and found some of the existing practice confusing. As most of my previous experiences are on Oracle and Unix platform so would...
5
by: jib | last post by:
How do I redirect a hyperlink column's URL when the URL doesn't exist? Is it possible to set a default URL for the Hyperlink button? Thanks, Jib
1
by: Amil | last post by:
I have a page with a hyperlink (actually in a datalist). I want the URL to do a postback essentially. I tried to use Page.Request in the NavigateUrl, but it's always empty? How do I tell it to...
0
by: VB Programmer | last post by:
I have this hyperlink in a datalist that is supposed to automatically include the current "ListingId" field in the hyperlink navigateurl. <asp:HyperLink id="hlView" runat="server"...
0
by: shaqattack1992-newsgroups | last post by:
I have a table with a hyperlink field pointing to an Excel file that I would like to automatically print out on a report form. For example, I have a table: Part--------Drawing(hyperlink field)...
4
by: sulemanzia | last post by:
I have a form with a Command button. i have a text box also which is bound to my Button. i have created a standard module and created an onclick event for my button which is something like this (...
2
by: John | last post by:
I have an Access 2000 form that has a Hyperlink that opens an Excel 2000 worksheet located in the same network folder as the Access MDB. The Hyperlink works great. When users close the Excel...
6
by: Chris | last post by:
Hi, When the length of a textbox in a form exceeds the length of the corresponding field, i get an error message ("string or binary data will be truncated .... ") and the aplication stops. I...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.