我有一个关于.live
触摸事件的简单问题。我想要做的是当用户点击/触摸页面主体(容器)时,该refreshCanvas
函数被调用。但是,这似乎对我不起作用。
JavaScript:
<script type="text/javascript">
function refreshCanvas () {
var code = document.getElementById('iframe');
code.src = code.src; // that is the essence here
}
setInterval(refreshIframe1, 20000);
function refreshIframe1() {
$("#iframe")[0].src = $("#iframe")[0].src;
}
$('#container').live("tap", function() {
refreshCanvas();
});
</script>
HTML:
<a href="javascript:refreshCanvas()"><img src="data/refresh.jpg"></a>
<div id="container">
<iframe id="iframe" src="data/canvas.html" z-index: 0; style="border: 0; position:absolute; top:0; left:0; right:0; bottom:0; width:100%; height:100%"></iframe>
</div>