Record and replay Javascript

前端 未结 6 980
时光取名叫无心
时光取名叫无心 2020-12-23 23:09

I know it is possible to record mouse movements, scrolling and keystrokes. But what about changes to the document? How can I record changes to the document?

Here is

6条回答
  •  盖世英雄少女心
    2020-12-23 23:27

    I believe you are looking for Mutation Events.

    http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-mutationevents

    Here are some resources for you:

    http://tobiasz123.wordpress.com/2009/01/19/utilizing-mutation-events-for-automatic-and-persistent-event-attaching/

    http://forum.jquery.com/topic/mutation-events-12-1-2010

    https://github.com/jollytoad/jquery.mutation-events

    Update:

    In Response to comment, a very, very basic implementation:

    //callback function
    function onNodeInserted(){alert('inserted')}
    //add listener to dom(in this case the body tag)
    document.body.addEventListener ('DOMNodeInserted', onNodeInserted, false); 
    //Add element to dom 
    $('
    test
    ').appendTo('body')

    Like WTK said, you are getting yourself into complex territory.

提交回复
热议问题