PDA

View Full Version : Resolved Live Character Counter Does not Work on IE



Buk
01-30-2011, 08:05 AM
I have tried code below on my localhost. It worked fine on firefox but does not work on internet explorer. However if i click the demo (http://demos.9lessons.info/loadbar.html) where i get the code, it works on both firefox and ie. I have very shallow knowledge about javascript jquery and cross browser compatibility therefore i couldn't work it on internet explorer.
Thanks in advance.

<html>
<head>
<link href="style.css" media="screen" rel="Stylesheet" type="text/css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">

/* Sayaç textarea fonksiyonu */
$(document).ready(function()
{
$("#contentbox").keyup(function()
{
var box=$(this).val();
var main = box.length *100;
var value = main / 145;
var count = 145 - box.length;

if(box.length <= 145)
{
$('#count').html(count);
$('#bar').animate(
{
"width": value+'%',
}, 1);
}
else
{
alert(' Full ');
}
return false;
});

});
/* Sayaç textarea fonksiyonu */
</script>
</head>
<body>

<div>
<div id="count">145</div>
<div id="barbox"><div id="bar"></div></div>
</div>
<textarea id="contentbox"></textarea>
</body>
</html>


style.css

#bar
{
background-color:#5fbbde;
width:0px;
height:16px;
}
#barbox
{
float:right;
height:16px;
background-color:#FFFFFF;
width:100px;
border:solid 2px #000;
margin-right:3px;
-webkit-border-radius:5px;-moz-border-radius:5px;
}
#count
{
float:right; margin-right:8px;
font-family:’Georgia’, Times New Roman, Times, serif;
font-size:16px;
font-weight:bold;
color:#666666
}
#contentbox
{
width:450px; height:50px;
border:solid 2px #006699;
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
}

Buk
01-31-2011, 01:00 PM
I haven't find any solution yet. Waiting for helps :)

Kor
01-31-2011, 02:01 PM
Start by giving your document a certain Doctype (http://www.w3schools.com/tags/tag_doctype.asp)

Buk
01-31-2011, 04:18 PM
Thank you Kor. I have started Doctype but forgotten a sentence before doctype. I have solved it :)