469,366 Members | 2,322 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

Is it possible to force re-avaluating/re-parsing of HTML?


Ran into the following problem while trying to have a code to
attach a Virtual Keyboard to any user's form:

User clicks a button and my JavaScript changes outerHTML
of say <textarea - adding things like ONCLICK='saveCaret(this)'
etc. and it also tries to save any text that user could've entered
before the button press.

a) Value - (already typed text) is not assigned back
b) outerHTML is still the same - both in alert() text and via
javascript:x=document.body.innerHTML.replace(/</g,'&lt;').replace(/\n/g,'<br>'); document.body.innerHTML = x;
The code is simple so I wander whether we have a way to force HTML to be
re-avaluated/re-parsed via a button click

(if I do the same via <script....</scriptline placed above the button
then everything is OK - because HTML is being changed _before_ the
page load is over)

function vkb_addAttributes(obj)

var obj_value = ""; if (obj.value != "") obj_value = obj.value;
var kA=" onFocus='vkb_txtControl=this;' OnSelect='vkb_saveCaret(this)'";

var obj_HTML = obj.outerHTML;
var pos = obj_HTML.indexOf('>');
var part1 = obj_HTML.substring(0,pos);
var part2 = obj_HTML.substring(pos);
obj.outerHTML = part1 + kA + part2;

obj.value = obj_value;

Sep 25 '06
51 4085
GLC wrote:
Yep, sorry. Somebody passed along some bad info.
Garbage in, garbage out ;-)
After the e.cancelBubble line, add this:

e.preventDefault? e.preventDefault() : e.returnValue = false;

I tested this on IE6 and Firefox
Thanks - and it makes sense now for me after Rob's and your
input - as a guy in my favorite movie "Oscar" says,
"I am getting good at this!" - I am starting to grasp the idea :)
Oct 11 '06 #51
RobG wrote:
Returning true or false to the event handler has no effect on event
... looks like evt.preventDefault is different
from e.cancelBubble/e.stopPropagation()

Yes, see my other post for links.
Thanks, it's very helpful!

Oct 11 '06 #52

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by infidel | last post: by
5 posts views Thread by craig | last post: by
1 post views Thread by nightowlky | last post: by
11 posts views Thread by gregory_may | last post: by
reply views Thread by comp.lang.php | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.