的jQuery
$('a.popup').click(function(){
window.open( this.href, 'Page title', 'width=600, height=650' );
return false;
});
HTML
<a class="popup" href="sample.html">
如果在弹出窗口中打开我的sample.html
页面,我想隐藏页眉和页脚。我可以将类名添加到弹出窗口的<html>
或<body>
吗?所以我可以添加CSS规则。谢谢!
答案 0 :(得分:3)
来自sample.html
部分的<head>
,只检查window.opener
是否存在,例如
<script>
if (window.opener) {
/* i'm a popup, add "popup" class to <html> element */
document.documentElement.className += " popup";
}
</script>
然后您可以使用类.popup
设置自己的CSS样式,例如
header { display: block; }
.popup header { display: none; }