Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts

    Is it possible to add colour and links to my news ticker (code included)

    Hi All

    I Have a news ticker and cannot manage to add a link nor change the font colour of parts of the ticker.

    the code is:
    <code>
    <!--
    // please keep these lines on when you copy the source
    // made by: Nicolas - http://www.javascript-page.com

    var tags_before_clock = "";
    var tags_after_clock = "";
    var speed = 100;
    var speed2 = 2000;

    function initArray() {

    this.length = initArray.arguments.length;
    for (var i = 0; i < this.length; i++) {
    this[i] = initArray.arguments[i];
    }
    }

    var mymessage = new initArray(
    "Latest News: Site Updated 11 June 08",
    "New Store Added: Betterware - Misc - 10 June 08",
    "New Store Added: Jamster - Misc - 8 June 08",
    "New Store Added: Butlins - Misc - 2 June 08"
    );

    var mymessage2 = mymessage;
    var x = 0;
    var y = 0;

    if(navigator.appName == "Netscape") {
    document.write('<layer id="ticker"></layer><br>');
    }

    if (navigator.appVersion.indexOf("MSIE") != -1){
    document.write('<span id="ticker"></span><br>');
    }

    function upticker(){

    if (y > mymessage2.length - 1) {
    y = 0;
    setTimeout("upticker()",speed);
    }

    else{

    if (x > mymessage2[y].length) {
    mymessage = mymessage2[y];
    x = 0; y++;
    setTimeout("upticker()",speed2);
    }

    else {
    mymessage = mymessage2[y].substring(0,x++);
    setTimeout("upticker()",speed);
    }

    if(navigator.appName == "Netscape") {
    document.ticker.document.write(tags_before_clock+mymessage+tags_after_clock);
    document.ticker.document.close();
    }

    if (navigator.appVersion.indexOf("MSIE") != -1){
    ticker.innerHTML = tags_before_clock+mymessage+tags_after_clock;
    }
    }
    }

    setTimeout("upticker()",speed);
    //-->
    </code>
    The text in bold i want linked to a page in the directory called misc.html and i want the text colour red, is this possible.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,147
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    If you look at the original version, you will see that you can add html tags at

    var tags_before_clock = "";
    var tags_after_clock = "";

    "If you want to customize your text in any way (color, size, center, etc.), put in the appropriate beginning and ending HTML tags in these two sections."

    e.g:

    var tags_before_clock = "<font face = "Arial" color = "red"><big>";
    var tags_after_clock = "</color></big></font>";


    But this is an old script (1999?) and these days the <font> tag is deprecated.

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts
    Hi Philip,

    I think if i enter tags where you said it would link all the text and make the entire sectence red? i only want a couple of words red and linked within each sentence, i might be wrong tho

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,147
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    Try building it into the message text:-

    <font color = "blue"><b><a href = http://www.yourdomain.com/page.html>misc</a></b></font>

    or create a new variable

    var tags_before_misc = "<font color = 'blue'><b><a href = http://www.yourdomain.com/page.html>"

    and build up your message thus:-

    ticker.innerHTML = tags_before_clock + mymessagePART1 + tags_before_misc + "MISC" + tags_after_misc + mymessagePART2 + tags_after_clock;

    As I say, this is old code containing deprecated elements which may not be supported in future browsers. It would be best completely re-written using CSS.

  • #5
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts
    Hi Philip

    unfortunatly this didn't work like you say the whole thing probabily needs re-writing in CSS,( i had better start learning css ) never mind

    Thanks For Your Time and Help
    Luke


  •  

    Posting Permissions

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