SitePoint Sponsor

User Tag List

Results 1 to 21 of 21
  1. #1
    SitePoint Enthusiast tenfingers's Avatar
    Join Date
    May 2004
    Location
    Alberta, Canada
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Check a script for errors or 'bad' programming

    What is wrong with this script (if anything)?

    Code:
    // start mailTo script
    // Copyright 2007
    // my.tenfingers.net
    var addr=new Array();
    // Look-up table consists of six columns, 0..5.
    /* Published prompt is stored in column 0 of the table.
     * Eg. addr[6] below.
     * Column 1 of the table stores Tooltip text.
     * Column 2 stores actual recipient name portion of address;
     * Column 3 stores actual recipient domain portion of address;
     * Column 4 stores a mirror of c.2 and column 5 mirrors c.3 when the actual address is published.
     * Leave column 4 of the table empty to publish plain link text stored in column 5 of the table.
     * Eg. addr[5] below.
     * HTML allowed in c.4 and c.5, eg. addr[0], or, as in addr[5], in c.5 alone.
     * Reset outdated rows to empty single quotes, and re-use. */
    // Do not shift rows or your pages will be publishing errant data.
    addr[0]=['','Comments and general enquiries','admin','domain.com','<strong>admin','domain.com<\/strong>'];
    addr[1]=['','Advertsing, Billing and Accounts Payable','admin','domain.com','admin','domain.com'];
    addr[2]=['','Contact Person One','person.one','domain.com','person.one','domain.com'];
    addr[3]=['','Contact Person Two','person.two','domain.com','person.one','domain.com'];
    addr[4]=['','Contact domain.com webmaster','webmaster','domain.com','webmaster','domain.com'];
    addr[5]=['','Report Problems','webmaster','domain.com','','<em>Report Problems<\/em>'];
    addr[6]=['Contact:','Contact domain.com webmaster','webmaster','domain.com','','Webmaster'];
    addr[7]=['\,','Discuss Privacy with domain.com webmaster','webmaster','domain.com','webmaster','domain.com'];
    addr[8]=['\, or by e-mail to','Comments and general enquiries','admin','domain.com','<strong>admin','domain.com<\/strong>'];
    addr[9]=['','Sales Inquiries and Visitor Comments','sales','domain.com','sales','domain.com'];
    // An empty argument, zero value, or empty quotes will disable the script at point of occurance.
    // Eg. doMailto(); or, doMailto(0); or, doMailto("");
    function inValid(arg) {return (arg==null||arg==0||arg=="");}
    // Output is one mail or text link inline with the document flow.
    // Eg. addr[8] above is in the flow of a sentence. Note HTML in c.4 and c.5
    // The span wrapping the published text is included for user styles.
    function doMailto(sendTo) { if(inValid(sendTo)) return;
    	var y=eval(sendTo); if(y<=0||y>addr.length) {return} else {y=y-1};
    	var line,xPt,xTo,isM,isA,text,atC='&#064\;';
    	xPt=addr[y][0]; xPt=xPt==""? '' : xPt+'&nbsp;';
    	xTo=addr[y][2]+atC+addr[y][3];
    	isM=addr[y][4];	isA=addr[y][5]; text=isM==""? isA : isM+atC+isA;
    	line=xPt+"<a title=\""+addr[y][1]+"\" href=\"mailto:"+xTo+"\"><span>"+text+"<\/span><\/a>";
    	document.write(line);
    	}
    // end mailTo script
    Just the script:

    Code:
    // Copyright 2007
    // my.tenfingers.net
    var addr=new Array();
    addr[0]=['','Comments and general enquiries','admin','domain.com','<strong>admin','domain.com<\/strong>'];
    addr[1]=['','Advertsing, Billing and Accounts Payable','admin','domain.com','admin','domain.com'];
    addr[2]=['','Contact Person One','person.one','domain.com','person.one','domain.com'];
    addr[3]=['','Contact Person Two','person.two','domain.com.com','person.one','domain.com'];
    addr[4]=['','Contact domain.com webmaster','webmaster','domain.com','webmaster','domain.com'];
    addr[5]=['','Report Problems','webmaster','domain.com','','<em>Report Problems<\/em>'];
    addr[6]=['Contact:','Contact domain.com webmaster','webmaster','domain.com','','Webmaster'];
    addr[7]=['\,','Discuss Privacy with domain.com webmaster','webmaster','domain.com','webmaster','domain.com'];
    addr[8]=['\, or by e-mail to','Comments and general enquiries','admin','domain.com','<strong>admin','domain.com<\/strong>'];
    addr[9]=['','Sales Inquiries and Visitor Comments','sales','domain.com','sales','domain.com'];
    function inValid(arg) {return (arg==null||arg==0||arg=="");}
    function doMailto(sendTo) { if(inValid(sendTo)) return;
    	var y=eval(sendTo); if(y<=0||y>addr.length) {return} else {y=y-1};
    	var line,xPt,xTo,isM,isA,text,atC='&#064\;';
    	xPt=addr[y][0]; xPt=xPt==""? '' : xPt+'&nbsp;';
    	xTo=addr[y][2]+atC+addr[y][3];
    	isM=addr[y][4];	isA=addr[y][5]; text=isM==""? isA : isM+atC+isA;
    	line=xPt+"<a title=\""+addr[y][1]+"\" href=\"mailto:"+xTo+"\"><span>"+text+"<\/span><\/a>";
    	document.write(line);
    	}
    I'm not a programmer, and have only begun to scratch the surface of Javascript programming so I cannot tell whether anything is wrong or not. The script performs flawlessly in IE, FF, Opera and Safari for Windows.

    The look-up table consists of 6 columns, as described in the annotation above. The reasoning for the first column is that if scripting is disabled, then so too should the visible prompt. Nothing looks dumber than E-mail: with nothing following (imho).

    The tooltip text is optional, but one reasons that most users will appreciate seeing where a link is taking them, or at least some description of the link.

    Columns 3 and 4 (2 & 3 , actually) are crucial, as they contain the values that will accompany mailto: in the hook reference. Columns 5 and 6 (4 & 5) are the visible portion of the link on the screen. If column 5 contains a value, it will be concatenated with @ and the contents of column 6. If c.5 is left empty, then only the regular text expression in column 6 is published. HTML tags are allowed in these two columns.

    To temporarily disable a link, set the argument value [doMailto(arg)] to NULL, ZERO, or empty quotes.

    Furthermore, structural markup may be included inside the script tags, wrapping the doMailto(); function call. The script output is inline, so may even be inserted in the middle of a sentence. Noscript tags are optional, but implementation of the tags inline can be a problem, since it's not valid. For this, I use p tags styled inline to bookend the script, giving the output the appearance of being inline. Then my noscript can contain alternate text inside p tags (again styled inline) and replace the link text (with a phone number or a link to the contact page) like nothing is missing.

    I would greatly appreciate any comments or corrections to the above. Thanks!

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I think what is most wrong with this script is that it's unnecessary. This sort of thing should be done on the server side, then all the other wrong things would be avoided. The biggest wrong thing is the use of inline scripting in the body (document.write). It's horribly messy and a pain to maintain. This could be done more easily and more cleanly with a more unobtrusive method. The use of eval() is also not good and likely avoidable. The "inValid" function also seems to be unnecessary.

    What do you use the argument for doMailTo() ? A sample would be useful.

  3. #3
    SitePoint Enthusiast tenfingers's Avatar
    Join Date
    May 2004
    Location
    Alberta, Canada
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The argument for doMailto(); is the physical row number in the look-up table of the e-mail link one wishes to publish in the page.
    Code:
    <script type="text/javascript">doMailto(1);</script>
    The use of eval() was the simplest means of stripping quotes from the argument, eg. ("1"), which would be a valid argument. If text is supplied as an argument, it is ignored and the script terminates.

    The inValid(arg) function is mainly there to prevent script errors if the argument is accidentally (or purposefully) left as NULL.

    All of my sites are hand coded and hardwired (no php or database, no server side includes). Consequently, I have to rely on client side scripts.

  4. #4
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    parseInt is much more suitable in this case than eval (that's what it's for).

    Doing this:
    Code:
    if (!sendTo) return;
    is the same as what the inValid function does. null, 0 and "" all evaluate to false, so the code in the above box will do.

    If you take these suggestions into account and put the javascript in an external file and stop using document.write, I think it should be quite sound.

  5. #5
    SitePoint Enthusiast tenfingers's Avatar
    Join Date
    May 2004
    Location
    Alberta, Canada
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this what you mean?
    Code:
    function doMailto(sendTo) {
    	var y=parseInt(sendTo,10); if(isNaN(y)) return;
    	if(y<=0||y>addr.length) {return} else {y=y-1};
    	var line,xPt,xTo,isM,isA,text,atC='&#064\;';
    	xPt=addr[y][0]; xPt=xPt==""? '' : xPt+'&nbsp\;';
    	xTo=addr[y][2]+atC+addr[y][3];
    	isM=addr[y][4];	isA=addr[y][5]; text=isM==""? isA : isM+atC+isA;
    	line=xPt+"<a title=\""+addr[y][1]+"\" href=\"mailto:"+xTo+"\"><span>"+text+"<\/span><\/a>";
    	document.write(line);
    	}
    The script resides in an external library for universal access and easy maintenance.

    What I'm not clear on is what to use instead of document.write. Will need to do some reading. Thanks for the pointers.

  6. #6
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Much better I think. Instead of document.write I think you should use DOM methods. For example, say you have this:
    HTML Code:
    <p>bla bla bla bla bla bla..... please contact <a href="mailto:admin@example.com" title="Comments and general enquiries" id="contactus">the administration</a> and we'll answer as soon as possible</p>
    Then you could turn your script into this:
    Code Javascript:
    function doMailto(sendTo) {
    	var y = parseInt(sendTo,10);
    	if (isNaN(y) || y <= 0 || y > addr.length) return;
    	else y = y - 1;
    	var c = document.getElementById('contactus'), xPt, isM, atC='&#064\;';
    	xPt = addr[y][0];
    	isM = addr[y][4];
    	if (xPt) c.parentNode.insertBefore(document.createTextNode(xPt + ' '), c);
    	c.title = addr[y][1];
    	c.href = 'mailto' + addr[y][2] + atC + addr[y][3];
    	c.innerHTML = isM ? isM + atC + addr[y][5] : addr[y][5];
    }
     
    window.onload = doMailto(1);
    A bit more condensed, more readable (although you could choose more meaningful variable names, the extra bytes used will be worth it).

    I'm don't think you're supposed to escape the semi-colon when it's in a string. I also don't think you need to escape the comma in a string in an array element (in your array definitions).

    For the text in the anchor, I used innerHTML because isM might contain some HTML tags, from what I see in your array definition in your first post.

  7. #7
    SitePoint Enthusiast tenfingers's Avatar
    Join Date
    May 2004
    Location
    Alberta, Canada
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very elegant. Thank you for your excellent example.

    This one look-up table contains all e-mail link information for the entire site. On some pages, such as the contact page, there are multiple calls to the doMailto() function.

    As it stands, there are no unique or special identifiers for these links, just the script tags, the numeric argument and the occasional noscript. The script does not require any class or id in the HTML, and no structural markup beyond its parent element (likely a p) and the contained optional span.

    The anchor tag is in the script, so where do I put the id for getElementById?

    I'm not sure how one would implement window.onload for this function under these conditions. Would I need a more complex script to sniff out all the function calls in a given page, and deal with them in place?

  8. #8
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The way I did it, I've catered for the possibility of javascript being unavailable, thus meaning noscript tags are unnecessary. As it is, the anchor is already there with a "default" email address (the admin one) and so if javascript is available, it changes it to the more specific address.

    If you're going to do this several times, then change the script to this:
    Code Javascript:
    function doMailto(c, sendTo) {
        var y = parseInt(sendTo,10);
        if (isNaN(y) || y <= 0 || y > addr.length) return;
        else y = y - 1;
        var xPt = addr[y][0], isM = addr[y][4];
        if (xPt) c.parentNode.insertBefore(document.createTextNode(xPt + ' '), c);
        c.title = addr[y][1];
        c.href = 'mailto:' + addr[y][2] + '@' + addr[y][3];
        c.innerHTML = isM ? isM + '@' + addr[y][5] : addr[y][5];
    }
     
    function init() {
      doMailto('contact_person1', 1);
      doMailto('contact_person2', 2);
      doMailto('contact_webmaster', 4);
    }
     
    window.onload = init;
    So in the doMailto you now need to specify the ID of the anchor that you want to affect. If you look at the HTML code I posted above, the anchor has the id "contactus", so the only change in the HTML you really need to do is add a "default" anchor and give each one you want doMailto to change an ID.

  9. #9
    SitePoint Enthusiast tenfingers's Avatar
    Join Date
    May 2004
    Location
    Alberta, Canada
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, Raffles. Your example is really a thing of beauty. Is it feasible to place the init function in the head section of a given page, to maintain customization, etcetera? I especially like the fact that script tags are removed from the document markup.

    I ought to have been more explicit about the real purpose of this script--to obfuscate e-mail addresses and keep them out of the hands of spam bots. I used to use a much more primitive method using unique functions and gobs of document.writes. Either way, the method has kept the inboxes of all my sites free of spam for years. So I have a wee problem with the mailto attribute being coded into the page--it defeats the purpose of the script.

    However, just as my noscript usually provides a ink to the contact page, I could just code it that way, with unique ids, as you suggest. On the contact page itself, links could just point to the section with telephone and mailing address.

    My recent goal was to create a better script, which I had (or at first thought). Thank heaven I stuck my neck out enough to learn the better way. It really was worth the effort.

  10. #10
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You're welcome.

    Now I understand what this is all about. So obviously you need some other placeholder instead of a default email address. That's up to you of course, but you really should provide a method for people to actually be able to email you. Perhaps by linking to a contact form or by using an image. 99&#37; (or thereabouts) of people have javascript enabled, so showing an image to the other 1% is not too bad.

    And yes, you can put the init function directly in the head to customise it as you go along. The rest can go in an external javascript file. You might have to put the script tags for the init function before those for the external file, though I don't think this should be necessary.

  11. #11
    SitePoint Enthusiast tenfingers's Avatar
    Join Date
    May 2004
    Location
    Alberta, Canada
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, now I have another problem to deal with: conflict with Kravitz's Universal Bookmark Script dss_addevent. Is there some way to register these two onload events, but in the head section, to support page customization? The main scripts are all external.

    As it was before, doMailto() had no associated onload events, so this was not a problem.

  12. #12
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Let's say Kravvitz's script includes the following:
    Code:
    window.onload = function() {
      doThis();
      doThat();
    }
    Just combine them with the window.onload stuff above:
    Code:
    window.onload = function() {
      doMailto('contact_person1', 1);
      doMailto('contact_person2', 2);
      doMailto('contact_webmaster', 4);
      doThis();
      doThat();
    }
    Alternatively, put doThis and doThat inside the init() function we defined before.

  13. #13
    SitePoint Enthusiast tenfingers's Avatar
    Join Date
    May 2004
    Location
    Alberta, Canada
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not having any success with even a bare window.onload, so I'm falling back on the kick-to-the-curb version for the time being.
    Code:
    function doMailto(sendTo) {
    	var y = parseInt(sendTo,10);
    	if (isNaN(y) || y <= 0 || y>addr.length) return;
    	else y = y - 1;
    	var scrPrompt = addr[y][0]? addr[y][0]+' ' : '';
    	var atC ='@', hookRef = addr[y][2]+atC+addr[y][3];
    	var linkText = addr[y][4]? addr[y][4]+atC+addr[y][5] : addr[y][5];
    	var toDisplay = scrPrompt +'<a title="'+ addr[y][1] +'" href="mailto:'+ hookRef +'"><span>'+ linkText +'<\/span><\/a>';
    	document.write(toDisplay);
    	}
    With my level of troubleshooting skills, DOM methods are obviously going to take a while for this old brain to wrap around. Up to now, and with what time I've had , it's been whatever gives the appearance of working, which one must almost be certain broke every rule in the book. From this level, it's almost enough to be able to go to sleep knowing that everything works as best as we can make it.

    One grows awfully humble strolling along the halls of SitePoint, especially when one walks these halls unaccompanied, as most of us must have done at one time or another. It's easy to be distracted by all the portraits along the corridors. But more to the point, I should hate to squander all that's laid out before me. SP is by all accounts a community of experts that seem to agree on the things that matter most. I only hope it's not all lost on my poor old noggin.
    Last edited by tenfingers; Aug 22, 2007 at 03:40. Reason: Additional commentary

  14. #14
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'd recommend installing the Firebug extension for Firefox which should help you work out what is wrong with the code.

  15. #15
    SitePoint Enthusiast tenfingers's Avatar
    Join Date
    May 2004
    Location
    Alberta, Canada
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not getting any script errors, but it's like the window.onload simply doesn't occur.
    HTML Code:
    <script type="text/javascript" src="externalscript.js"></script>
    <script type="text/javascript">
    function init() {
      doMailto('admin_phrase',11);
    }
    
    window.onload = init;</script>
    </head>
    The doMailto() object and addr arrary are listed in the DOM, but not the init() object. All other onload events are suspended (addBookmark).

    Using your (Raffles) code above (with revised variable names) in the external .js along with the main array.
    Code:
    function doMailto(thisElement, sendTo) {
        var y = parseInt(sendTo,10);
        if (isNaN(y) || y <= 0 || y > addr.length) return;
        else y = y - 1;
        var screenPrompt = addr[y][0], isRecipient = addr[y][4];
        if (screenPrompt) thisElement.parentNode.insertBefore(document.createTextNode(screenPrompt + ' '), thisElement);
        thisElement.title = addr[y][1];
        thisElement.href = 'mailto:' + addr[y][2] + '@' + addr[y][3];
        thisElement.innerHTML = isRecipient ? isRecipient + '@' + addr[y][5] : addr[y][5];
    }
    Last edited by tenfingers; Aug 22, 2007 at 16:38. Reason: Additional content

  16. #16
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It's not working because sendTo (11 in this case) is bigger than addr.length (which I believe was 10). The second line in doMailto() means that the function exits when y > addr.length.

    If this is still the case when sendTo is less than addr.length, try and debug this by throwing a few alert()s in there at certain steps of the way. For instance, put one inside init(). Then if you get the alert when you load the page, you know window.onload = init is working. Then put one at key positions in doMailto until the alert box doesn't pop up - then you know the error is somewhere just before wherever you put the alert().

    You don't need to specify the radix (second argument) in parseInt. And what do you mean by "listed in the DOM"? The addr array is simply a Javascript array, it has nothing to do with the DOM. The same with doMailto - it's just a JS function.

  17. #17
    SitePoint Enthusiast tenfingers's Avatar
    Join Date
    May 2004
    Location
    Alberta, Canada
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    While those things 'have nothing to do with the DOM' they show up under DOM in Fire Bug. Easy to see how that might confuse one. init() is there, now, and so is onload.

    Is there some way to dump a variable list? Some appear, and others don't.

    I'll try as suggested with the cursory alerts to see where the pencil line breaks. Thanks.

  18. #18
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Oh I see, sorry. I think my view of the DOM might be too simplistic.

    For dumping variables, with Firefox you can use dump(), which dumps them to the javascript console (have a look on developer.mozilla.org for documentation on it). I don't think it'll just do something like dump all variables though, you have to explicitly say which ones.

    Is this live in one of those links you PMed me? Then I could have a better feel for what the problem is.

  19. #19
    SitePoint Enthusiast tenfingers's Avatar
    Join Date
    May 2004
    Location
    Alberta, Canada
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The url is in the documentation of the .js. I've created test copies called ____v2.

    I ran a cursory check and it stalls on the first method assignment, cc.
    (c. in the original). All cc. values are undefined. Should thisElement (the arg) be defined in the referring page?

  20. #20
    SitePoint Enthusiast tenfingers's Avatar
    Join Date
    May 2004
    Location
    Alberta, Canada
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Man-oh-man-oh-man

    So I guess this is where I ought to begin: Insert in place without document.write I'm off...

    Well, I'm back. This brings be right back to the original script inline approach I originally contrived, save now I can id them and grind out the rendering via the DOM. This will take some study. See ya next week!
    Last edited by tenfingers; Aug 28, 2007 at 02:29. Reason: Obvious

  21. #21
    SitePoint Enthusiast tenfingers's Avatar
    Join Date
    May 2004
    Location
    Alberta, Canada
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Finally have a working version of Raffles' suggested code. This is in mainscript.js file along with the addr array, which is unchanged.
    Code:
    function mailTo(thisElement, sendTo) {
    	if(!document.getElementById) return;
    	var y = parseInt(sendTo,10);
    	if (isNaN(y) || y <= 0 || y > addr.length) return;
    		else y = y - 1;
    	var cc = document.getElementById(thisElement);
    	var screenPrompt = addr[y][0], isRecipient = addr[y][4];
    	if (screenPrompt) cc.parentNode.insertBefore(document.createTextNode(screenPrompt + ' '), cc);
    	cc.title = addr[y][1];
    	cc.href = 'mailto:' + addr[y][2] + '@' + addr[y][3];
    	cc.innerHTML = isRecipient ? isRecipient + '@' + addr[y][5] : addr[y][5];
    };
    The mainscript.js file is loaded just ahead of the load function for this method.
    HTML Code:
    <head>
    ...
    <script type="text/javascript" src="../jscript/mainscript.js"></script>
    <script type="text/javascript">
    var mailLink = function() {
    	var thisElement = 'mail_11';
    	var sendTo = 11;
    	mailTo(thisElement,sendTo);
    	};
    addEvent(window,"load",mailLink);
    </script>
    ...
    </head>
    This is the applicable row in the addr array:
    Code:
    addr[10]=['','Comments and general enquiries','admin','domain.com','','<strong>Please drop us a line<\/strong>'];
    HTML Code:
    <body>
    ...
    <a id="mail_11" href="../contact.htm" title="Contact Us" class="link">Contact Us</a>
    ...
    </body>
    The link class adds underlining to the link since it appears inline, in the context of the paragraph.

    The output is the default if the script fails or is disabled plus a noscript message when scripts are disabled; and "Please drop us a line." for this instance when all goes as planned. The link href is the contact page by default, and the mailto: referred to in the addr array on successful completion.

    The next trick will be to be able to cycle through an array of all element IDs that apply on the given page and apply appropriate content across the entire array. My attempts thus far have not worked... any takers?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •