...

View Full Version : Javascript is not working in other browser like Mozila, Chrome etc.



nkkhan81
03-04-2012, 05:22 AM
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:


<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

Old Pedant
03-04-2012, 07:10 AM
This line of code is extraneous and wrong:


if (document.all || document.getElementBy


start by getting rid of it.

nkkhan81
03-04-2012, 08:58 AM
This line of code is extraneous and wrong:


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

Philip M
03-04-2012, 10:43 AM
Shall I remove that line that you have mentioned?



No, of course not! Just do as Old Pedant says - and get rid of it! :rolleyes:

nkkhan81
03-04-2012, 12:11 PM
No, of course not! Just do as Old Pedant says - and get rid of it! :rolleyes:

Thanks philip. how to get rid of it? actualy I am new in Java....

Philip M
03-04-2012, 12:25 PM
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!

nkkhan81
03-04-2012, 12:53 PM
Thanks "Old Pedant" and "Philip M". The problem has been solved. :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum