<!--Demo: Using Javascript / JQuery to play back user actions on the web ->
<!--To run it, copy following content into a html file ->
<html>
<head>
<title>target</title>
<script type="text/javascript" src="./jquery-1.7.js"></script>
<script language="javascript">
var GlobalObjs = new Array();
function AttachRecordFunction()
{
var buttons = $(":button");
for (var i=0; i<buttons.length; ++i)
{
var btn = buttons[i];
$(btn).bind('click', Record);
}
}
function Record()
{
GlobalObjs.push(document.activeElement);
}
function Playback()
{
for (var i=0; i<GlobalObjs.length; ++i)
{
$(GlobalObjs[i]).unbind('click', Record);
$(GlobalObjs[i]).trigger('click');
}
}
function BtnClickEvent(str)
{
alert(str);
}
</script>
</head>
<body>
<div>
<a href="#" οnclick="AttachRecordFunction();">Record</a>
<a href="#" οnclick="Playback();">PlayBack</a>
<button id="btnA" οnclick="BtnClickEvent('A');">Button A</click>
<button id="btnB" οnclick="BtnClickEvent('B');">Button B</click>
<button id="btnC" οnclick="BtnClickEvent('C');">Button C</click>
<div>
</body>
</html>