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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Post Javascript is not working in other browser like Mozila, Chrome etc.

    Hello,

    I have used a free javascript from javascriptkit.com for a "highlighter scroller" in my site. But the programe is only working in Internet explorer. When i use Mozila or google chrome, it is not appearing/working.

    Can anyone suggest me that how it will work in other browser also. here is the code that i used:

    Code:
    <div style="position:relative;left:0px;top:0px"> <span id="highlighter" style="position:absolute;left:0;top:0;font-size:15px;font-family:Calibri;background-color:lime;clip:rect(0px 0px auto 0px)"></span> </div>
                            <script type="text/javascript">
    
    /*
    Highligher Scroller script- By JavaScript Kit
    For this and over 400+ free scripts, visit http://www.javascriptkit.com/
    This notice must stay intact
    */
    
    var tickercontents=new Array()
    tickercontents[0]='<a href="ln.htm">IJSG Welcomes the Kingdom of Morocco as its new Member</a>'
    
    var tickdelay=3000 //delay btw messages
    var highlightspeed=10 //10 pixels at a time.
    
    ////Do not edit pass this line////////////////
    
    var currentmessage=0
    var clipwidth=0
    
    function changetickercontent(){
    crosstick.style.clip="rect(0px 0px auto 0px)"
    crosstick.innerHTML=tickercontents[currentmessage]
    highlightmsg()
    }
    
    function highlightmsg(){
    var msgwidth=crosstick.offsetWidth
    if (clipwidth<msgwidth){
    clipwidth+=highlightspeed
    crosstick.style.clip="rect(0px "+clipwidth+"px auto 0px)"
    beginclip=setTimeout("highlightmsg()",20)
    }
    else{
    clipwidth=0
    clearTimeout(beginclip)
    if (currentmessage==tickercontents.length-1) currentmessage=0
    else currentmessage++
    setTimeout("changetickercontent()",tickdelay)
    }
    }
    
    function start_ticking(){
    crosstick=document.getElementById? document.getElementById("highlighter") : document.all.highlighter
    crosstickParent=crosstick.parentNode? crosstick.parentNode : crosstick.parentElement
    if (parseInt(crosstick.offsetHeight)>0)
    crosstickParent.style.height=crosstick.offsetHeight+'px'
    else
    setTimeout("crosstickParent.style.height=crosstick.offsetHeight+'px'",100) //delay for Mozilla's sake
    changetickercontent()
    }
    
    if (document.all || document.getElementById)
    
    
    </script></td>
    Inside body I have used <body onload="populate();start_ticking()"> for multiple script in a page.

    Thank you in advance.

    Regards,
    Nazmul Karim Khan

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,664
    Thanks
    80
    Thanked 4,640 Times in 4,602 Posts
    This line of code is extraneous and wrong:
    Code:
    if (document.all || document.getElementBy
    start by getting rid of it.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    nkkhan81 (03-04-2012)

  • #3
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    This line of code is extraneous and wrong:
    Code:
    if (document.all || document.getElementBy
    start by getting rid of it.
    Thank you "Old Pedant" for your reply and observation. Could you please tell me the right code? so that it will work in Mozila and other browsers. Shall I remove that line that you have mentioned? Thanks a lot.....

    Nazmul
    Last edited by nkkhan81; 03-04-2012 at 09:03 AM.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Quote Originally Posted by nkkhan81 View Post
    Shall I remove that line that you have mentioned?
    No, of course not! Just do as Old Pedant says - and get rid of it!

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    No, of course not! Just do as Old Pedant says - and get rid of it!
    Thanks philip. how to get rid of it? actualy I am new in Java....

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Quote Originally Posted by nkkhan81 View Post
    Thanks philip. how to get rid of it? actualy I am new in Java....
    Just take it out!!

    This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • Users who have thanked Philip M for this post:

    nkkhan81 (03-04-2012)

  • #7
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Smile

    Thanks "Old Pedant" and "Philip M". The problem has been solved.


  •  

    Posting Permissions

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