- Forums - Reply - Statistics - Sign Up - Search -

The Wyzz WYSIWYG Editor / Coding Discussion / get javascripts Events like OnKeyUp and OnKeyDown
Author Message
manu
Member
# Posted: 25 May 2009 10:40


Hi there!

Thanks for this great tool!.

I just wanted to add a kind of counter that counts the number of characters entered by the user.
There are many code snippets that do this in Javascript. They generally use the 'onKeyup' and 'onKeyDown' events.

But with Wyzz it seems to be impossible to catch them. Is there a reason and is there a simple way to do this?

TIA

manu

RGaba
Member
# Posted: 2 Jun 2009 19:51


manu,
Something you're going to have to keep in mind is that the Wyzz Editor is a WYSIWYG Editor. Therefore, when the user types in "HI" it may only appear to be 2 characters, but by making it bold it will now be 17 characters due to the HTML code that is rendered in the background.

If you're still looking for something like this, I threw something together real quick.

1) Add this function to the very bottom of the wyzz.js:

function valueCount(n){

var valueSize = document.getElementById("wysiwyg" + n).contentWindow.document.body.innerHTML.length;
document.getElementById("characterCounter").inner HTML = valueSize +" Characters";
}


2) Next, you'll need to modify the code that creates the iFrame necessary for the Wyzz Editor. So, go in the wyzz.js file and replace lines 421 and 422 with the following code:

+ '<iframe frameborder="0" id="wysiwyg' + n + '" onblur="valueCount(\'' + n + '\');"></iframe>\n'
+ '</td></tr></table><br><span id="characterCounter"></span>\n';



Now, after you type in your message, tab off the field and you should see the counter appear.

Hope this helps!

manu
Member
# Posted: 17 Jun 2009 19:48


Thanks for your answer Rgaba.

I'll give a try and tell you if it's ok.

Cheers

manu

trco
Member
# Posted: 15 Aug 2009 18:11 - Edited by: trco


hi
i try this code, but nothnig change .....
and in function is error, there is a space ..."inner HTML" ....

can somebody repair code ? or update ??

UPDATE:
oh, its ok, i dont read "Now, after you type in your message, tab off the field and you should see the counter appear." ...
my english are bad, so write message and turn "Tab" button ...

RGaba
Member
# Posted: 15 Aug 2009 18:27 - Edited by: RGaba


So it's working for you now?

trco
Member
# Posted: 15 Aug 2009 18:33


yes, its work, i search something for some counter but it dont work ( wyzz + counter) problem are in ID on textarea ... but this help me ... thx ..

BTW : can you change on limit counter character ???? and change counter after 'onKeyup' or 'onKeyDown' event?? (dont use tab ) ... :-)

sory for my english ... he

RGaba
Member
# Posted: 15 Aug 2009 18:40


I tried it before with the onKeyUp and onKeyDown events but because it's an iFrame, you're limited to the type of events you can use. You could set a maxlength variable in the valueCount function and only display the characterCounter message if it exceeds your maxlength (like a validation).

trco
Member
# Posted: 15 Aug 2009 18:55


oh, i understand ...
1.and onChange, it work ??
2.and tags add in characterCounter ???

3. BTW.. on my web, i have mp3player in fla. i need click on menu button, change content, but music cant stop. if you understand me ...
frame are old, and my friend tell me the antivirus stop me ... its iframe safe ?? have you some alternative ?

RGaba
Member
# Posted: 17 Aug 2009 05:19


1) I believe, the only events that work with an iFrame are onBlur and onFocus (I'm not sure how this works across browsers though).

2) Not sure what you mean here in #2

3) If I understand you correctly, you want the music to continuously play while the visitor is on your site and not stop when they change pages. An iFrame resides on the page and will stop when you change pages. I think you would HAVE to do this using frames.

trco
Member
# Posted: 17 Aug 2009 07:22


1) On 3w. w3schools. com/TAGS/tag_textarea.asp write event who support, i think it may works .. Js isnt my strong site :-) ...

3) Frames are old way. not ?? my friend tell me ist not secure use frame, virus etc ... and antivirus stop the page when i use frameset ...

RGaba
Member
# Posted: 17 Aug 2009 13:44


1) You're not working with a textarea, you're text is being entered into an iFrame, therefore the onChange will not work.

3) There may be another way around it, you can try looking at this thread to see if it will help (change the _ to a . ):

www_webdeveloper_com/forum/showthread.php?t=164917

trco
Member
# Posted: 17 Aug 2009 14:58


1) yes, i found it ... thx

3)ehm very interesting, thx, i will look it .

Darren Dignam
Member
# Posted: 16 Sep 2009 16:18 - Edited by: Darren Dignam


Hi,
I think frames is one of those misunderstood HTML tages, like Tables. People either hate them, or love them. Used correctly though, and they are as useful as any other tag. There were concerns about frame security, but I think in a modern browser a user will be protected from XXS (cross site scripting). Anyway, with wyzz, the frame is being generated on-demand, and its contents are gentrated from your host... so where the virus you are so concerned about has come from, I dont know.
The concern I am dealing with at the moment is malacious vsitors to my site being able to inject javascript into the wyzz window, so if that content is then displayed on my site, strange things may happen. I am looking at ways of combating this server side, and if anyone has some good tips for either PHP or ASP I would like to know!

Moving back to the original question of capturing events in the iframe. On a normal document, i capture mouse events like this:
<script>
// detect browser....
gecko = (document.all) ? 0 : 1;
if(window.opera){gecko=false;operaBrowser=true;}

if (gecko)
{
document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
}
document.onmousedown = MouseDown;
document.onmousemove = MouseMove;
document.onmouseup = MouseUp;
</script>

Then have some functions named MouseUp or whatever to deal with the mouse.
Does anyone know if its possible to put this code (or similar) into the iFrame during makeWyzz or something, but use a function in the parent document as the event handler....
I will look into and report back....

Darren

RGaba
Member
# Posted: 16 Sep 2009 16:36


In regards to injecting javascript, have you seen this previous thread?
www_wyzz_info/forum/index.php?action=vthread&forum =3&topic=65

Darren Dignam
Member
# Posted: 16 Sep 2009 17:00


Hi,
yep, was just looking at that now as it happens. I am currently doing a replace "<script" with "", replace "onmouseover" with "rel" ect.... but that looks a lot more thorough!
cheers!

Your answer

Bold Style  Italic Style  Underlined Style  Image Link  URL Link  Disable BB codes *What's that?

 » Name  » Password 
 Only registered users can post here. Enter your login/password correctly before posting a message, or register first.
 

Powered by miniBB forum software © 2001-2010