本文介绍了innerHTML上的__defineSetter__阻止了它的呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在属性更改时使用__define[GS]etter__创建HTML元素的监视方法.当我设置该值时,它的响应很好,但是如果侦听的属性是innerHTML,则它某种程度上无法呈现给定的字符串.所以基本上,当我向innerHTML添加一些东西时,它不会显示.

i'm trying to create a watch method for HTML elements, using __define[GS]etter__ when a property is changed. It reacts just fine when i set the value, but if the property listened to, is innerHTML, it somehow fails to render the given string. So basically, when im adding something to innerHTML it doesn't show.

我使用上一个问题中所述的watch方法:注意JavaScript中对象属性的变化

Im using the watch method described in this previous question:Watch for object properties changes in JavaScript

我可能只是不听innerHTML的更改,但我也想知道__defineSetter__是否以某种方式阻止了设置值的原始处理.

I could of cause just not listen to innerHTML changes, but i'm also wondering if the __defineSetter__ somehow prevents original handling of setting the value.

谢谢!

推荐答案

我找到了另一个看上去有趣的网页,但是我无法完全按照自己的意愿去做: http://www.refactory.org/s/recent/tag/accessors

I found another webpage with something that looked interesting, but i couldn't quite get it to do what i wanted:http://www.refactory.org/s/recent/tag/accessors

我现在决定找到一种解决方法,它带有一个计时器,用于检查属性的更改以及支持该属性的浏览器的属性更改evnet.

I've decided to find a workaround for now, something with a timer that checks the attribute for changes and attribute change evnets for browsers that support that.

但是,如果有人找到问题的解答,请:)

But if any one finds a solution for the question plz post :)

这篇关于innerHTML上的__defineSetter__阻止了它的呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 11:49