这是代码:
1)jQuery:
<script src="Scripts/jquery.tools.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(function() {
// if the function argument is given to overlay,
// it is assumed to be the onBeforeLoad event listener
$("a[rel]").overlay({
mask: 'gray',
effect: 'apple',
onBeforeLoad: function() {
// grab wrapper element inside content
var wrap = this.getOverlay().find(".contentWrap");
// load the page specified in the trigger
wrap.load(this.getTrigger().attr("href"));
}
});
$("#target").keypress(function(event) {
// F1 pressed
if (event.keyCode == 112) {
alert("Help");
}
});
});
</script>
2)标记:
<!-- external page is given in the href attribute (as it should be) -->
<a href="WebForm1.aspx" rel="#overlay" style="text-decoration:none">
<!-- remember that you can use any element inside the trigger -->
<button type="button">Show external page in overlay</button>
</a>
<!-- another link. uses the same overlay -->
<a href="WebForm2.aspx" rel="#overlay" style="text-decoration:none">
<button type="button">Show another page</button>
</a>
<!-- overlayed element -->
<div class="apple_overlay" id="overlay">
<!-- the external content is loaded inside this tag -->
<div class="contentWrap"></div>
</div>
我在页面上有 2 个按钮,当单击其中任何一个按钮时,会显示带有一些文本的漂亮灰色层。如果我按 F1 键,我也想做同样的事情,就像我们寻求帮助一样。在此示例中出现消息框,但需要替换为灰色层。怎么做?