基于对海姆的信息的评论,你想要什么可以简化为:
$('#reload').click(function() {
$('#f1').attr('src', $('#f1').attr('src'));
return false;
});
或者
$('#reload').click(function() {
$('#f1')[0].contentWindow.location.reload(true);
return false;
});
但或许他的答案更符合您的需求。
UPDATE:
我使用我上面提供的方法放在一起的工作示例。我在一个页面中显示,显示打印时间的另一个页面。
的 HTML(time.html时):
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
The time is now <span id="time"></span>.
<script type="text/javascript">
$(document).ready(function() {
$('#time').html((new Date()).toString());
});
</script>
</body>
和父页面HTML(test.html中):
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
<iframe id="frame" src="file:///D:/Users/Cory/Desktop/time.html" width="500" height="250"></iframe>
<button id="reload">Refresh</button>
<script type="text/javascript">
$(document).ready(function() {
$('#reload').click(function() {
$('#frame').attr('src', $('#frame').attr('src'));
return false;
});
});
</script>
</body>
这一切正常,我在Firefox 3.6和IE 7.
这里是我的代码:
\t我更新但见@cory答案是好为你 – 2010-08-24 11:55:41