473,395 Members | 1,863 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.

Wrap inner table cell text with mailto...

10
hi,
i'm tring to get access to a cell inside a table that has the vlaue of an Email address but is not clickable.
i tring to go to that cell and Wrap the inner text with <a href="mailto... tag so it would be clickable.
i tried to use this code:
x=document.getElementById('GridView1').childNodes[14].childNodes[1];
but with no luck,for some resone i can't access the cell and it's text.

need you help on doing so...
Feb 3 '08 #1
1 2414
mrhoo
428 256MB
You may find it useful to use a general method for processing text-
deepText will pass all the text nodes that are descendants of a specified parent
to a specified function. Something like a recursive forEach method.

wrapTableMail is set up to process every table on the page, looking for valid email text, but you could specify one table,or one row to start from.

It will find common emails(joesmith@website.com), but you'll probably want a better Rx filter.

Expand|Select|Wrap|Line Numbers
  1. function deepText(hoo, fun) {
  2.     var A= [], next, T, pa, i;
  3.     if(!hoo) return A;
  4.     if(hoo.nodeType== 3) A.push(fun(hoo));
  5.     else if(hoo.hasChildNodes()) {
  6.         pa= hoo.childNodes, i= 0;
  7.         while(pa[i]){
  8.             next= pa[i++];
  9.             T= next.nodeType;
  10.             if(T== 3){
  11.                 if(/\w+/.test(next.data)) A.push(fun(next));
  12.             }
  13.             else if(T== 1) A= A.concat(arguments.callee(next, fun));
  14.         }
  15.     }
  16.     return A;
  17. }
Expand|Select|Wrap|Line Numbers
  1. function wrapTableMail(){
  2.     var T= document.getElementsByTagName('table');
  3.     var wrapN= document.getElementsByTagName('a').length;
  4.     var L= T.length, who;
  5.     var fun= function(hoo){
  6.         var Rx= /\b([\w]+(\.[\w-]+)*@([\w-]+\.)[a-z]{2,6})\b/i
  7.         if(hoo.data){
  8.             var pa= hoo.parentNode;
  9.             if(pa.nodeName== 'A') return;
  10.             var res,el;
  11.             var str= hoo.data;
  12.             var X= document.createElement('a');
  13.             X.className= 'wrapMailCss';
  14.             while(str && (res= Rx.exec(str)) != null){
  15.                 var tem= res[1];
  16.                 el= X.cloneNode(false);
  17.                 el.href= 'mailto:'+tem;
  18.                 el.appendChild(document.createTextNode(tem));
  19.                 hoo.replaceData(res.index,tem.length,'');
  20.                 hoo= hoo.splitText(res.index);
  21.                 str= hoo.data;
  22.                 if (str) pa.insertBefore(el, hoo);
  23.                 else pa.appendChild(el);
  24.                 Rx.lastIndex= 0;
  25.             }
  26.         }
  27.     }
  28.     while(L){
  29.         who= T[--L];
  30.         deepText(who,fun)
  31.     }
  32.  
  33.     // the rest is just success testing code
  34.     wrapN=document.getElementsByTagName('a').length-wrapN;
  35.     var s= (wrapN)+ ' mailto link';
  36.     if(wrapN>1) wrapN+= 's';
  37.     alert(s+' added');
  38. }
//call the function
wrapTableMail();
Feb 3 '08 #2

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

Similar topics

2
by: Paul E Collins | last post by:
I need to 'clip' text in a table cell instead of wrapping it, such that (i) the cell keeps its specified fixed width and (ii) any text that overflows the cell should be 'clipped' (hidden or...
3
by: JHR | last post by:
Hey all, I'm trying to make a sidebar box float to the right of various items, and for those items to wrap if a user shrinks his browser window. Instead, in every browser I've tried except for...
3
by: Richard | last post by:
Hi I am trying to place an e-mail link into a cell of an Access 2002 table. Have tried setting the cell as both a hyperlink and as plain text and putting the following into the box: <a...
2
by: Yeah | last post by:
Hi, all! I have a question. I am designing a listing similar to a phone book in HTML. Each listing has periods following it, but they must extend to the end of the table cell, and not wrap. ...
0
by: pamelafluente | last post by:
Hello experts, I need some help to do in a proper way what I am doing. I have some "cells" in a web page. Each "cell" is made of 2 DIV. One is inside the other. Example with 2 "cells" : <div...
10
by: Lorenzo Thurman | last post by:
I have a table cell that I want to wrap text inside of. I've tried both hard and soft wrap, but Firefox refuses to obey. IE 6&7 handle the wrap just fine. Does anyone know how I can fix this?
5
by: momo | last post by:
say i have the following table: <table width="500"> <tr> <td width="250">this is the text im concerned with</td> <td></td> </tr> </table> i need the width of the columns to STAY at 250 and...
1
by: Mr. SweatyFinger | last post by:
I can't get this to wrap in the table cell, or even not in a table cell How can i get the text to wrap??? <asp:Repeater ID="Repeater1" runat="server"...
1
by: bussasrinivas | last post by:
How to wrap up text shown with a table cell after a certain length intervals ? -------------------------------------------------------------------------------- I have a requirement to wrap a...
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.