Chrome doesn't react well to the innerText property:
Code:
<script type="text/javascript">
function createTextAreaWithLines(id)
{
var el = document.createElement('TEXTAREA');
var ta = document.getElementById(id);
var string = '';
for(var no=1;no<999;no++){ // 300 to 999
if(string.length>0)string += '\n';
string += no;
}
el.className = 'textAreaWithLines';
el.style.height = (ta.offsetHeight-3) + "px";
el.style.width = "30px";
//el.style.width = "29px"; // tried for chrome
el.style.position = "absolute";
el.style.overflow = 'hidden';
el.style.textAlign = 'center';
el.style.paddingRight = '0.2em';
//el.style.paddingRight = '0.9em'; // tried for chrome
el.innerHTML = string; //Firefox renders \n linebreak
el.innerText = string; //IE6 renders \n line break
el.style.zIndex = 0;
ta.style.zIndex = 1;
ta.style.position = "relative";
ta.parentNode.insertBefore(el, ta.nextSibling);
setLine();
ta.focus(); . . .
But since that's only for IE, we can use an IE conditional script comment for it:
Code:
<script type="text/javascript">
function createTextAreaWithLines(id)
{
var el = document.createElement('TEXTAREA');
var ta = document.getElementById(id);
var string = '';
for(var no=1;no<999;no++){ // 300 to 999
if(string.length>0)string += '\n';
string += no;
}
el.className = 'textAreaWithLines';
el.style.height = (ta.offsetHeight-3) + "px";
el.style.width = "30px";
//el.style.width = "29px"; // tried for chrome
el.style.position = "absolute";
el.style.overflow = 'hidden';
el.style.textAlign = 'center';
el.style.paddingRight = '0.2em';
//el.style.paddingRight = '0.9em'; // tried for chrome
el.innerHTML = string; //Firefox renders \n linebreak
/*@cc_on @*/
/*@if(@_jscript_version >= 5)
el.innerText = string; //IE6 renders \n line break
@end @*/
el.style.zIndex = 0;
ta.style.zIndex = 1;
ta.style.position = "relative";
ta.parentNode.insertBefore(el, ta.nextSibling);
setLine();
ta.focus(); . . .
By the way, since it doesn't change, all this stuff:
Code:
el.style.width = "30px";
el.style.position = "absolute";
el.style.overflow = 'hidden';
el.style.textAlign = 'center';
el.style.paddingRight = '0.2em';
Should be moved to the stylesheet:
Code:
<style type="text/css">
#editContent{
margin-left:40px;
padding-left:3px;
border:1px solid #666;
}
.textAreaWithLines{
display:block;
margin:0;
border:1px solid #666;
border-right:none;
background:#aaa;
position: absolute;
overflow: hidden;
text-align: center;
width: 30px;
padding-right: 0.2em;
}
textarea{
border:0px;margin:0px;padding:0px;
line-height:16px;
background-color:#FFFFFF;color:black;}
body{
color:#FFFFFF;
background-color:navy;
line-height:16px;
}
</style>
Bookmarks