Hi I would like to make counter of written characters in my iframe and when I trying to trigger onkeydown or onkeyup event in iframe the function which is assigned to this events doesn't work.
Here is JavaScript code :
var maxAmount = 250;
function textCounter(textField, showCountField){
alert('abc');
var numOfChars = textField.innerHTML.length;
if(numOfChars > maxAmount){
textField.innerHTML = textField.innerHTML.substring(0,maxAmount);
}
else{
showCountField.value = maxAmount - numOfChars;
}
}
And here is my HTML code :
<iframe name='richTextField' id='richTextField'
onkeydown='alert("abc");'
onclick='alert("abc");'
<!--
onkeydown='textCounter(this.form.richTextField,this.form.countDisplay);'
onkeyup='textCounter(this.form.richTextField,this.form.countDisplay);'
-->
></iframe>
<input readonly type='text' name='countDisplay' size='3' maxlength='3'
value='250'>Character remaining
<!-- End replacing your textarea -->
</form>
Before iframe element I have textarea element to pass what I will write in iframe to PHP script :
<form>
<!--Hide (but keep) your normal textarea and place in the iFrame replacement for it -->
<textarea name='myTextArea' id='myTextArea' cols='100' rows='14'></textarea>
But textarea has display:none css style to not interfere in iframe. I have placed there diagnosis alert('abc') functions but they doesn't work either.
Can anyone help with this problem ?