Updating page HTML causes endless loop

I'm writing a Firefox extension. The extension replaces certain words on the page with other words. Here's the basic code I'm using: function startup() { gBrowser.addEventListener("load", pageLoad, true); } function pageLoad(event) { if (event.originalTarget instanceof HTMLDocument) { var ht = content.document.body.innerHTML; ht = ht.replace(/\bthe\b/g,"el"); content.document.body.innerHTML = ht; } } The problem is that this code is causing an endless loop. When I set the innerHTML property of the body, it sends another load event, which causes the endless loop. How can I modify the page when it loads without causing the page load event to fire again?

以上就是Updating page HTML causes endless loop的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准