jsp <% %>和html标签一起使用示例,jsp布局中关于<iframe>标签的使用

iframe 元素会创建包括另外一个文档的内联框架(即行内框架)。

注意:在 HTML 4.1 Strict DTD 和 XHTML 1.0 Strict DTD 中,不支持 iframe 元素。

1.获取iframe的自适应大小,即:不适用height和width属性,而是用οnlοad="SetWinHeight(this);IFrameReSizeWidth(this)"方法

function SetWinHeight(obj)

{

var win=obj;

if (document.getElementById("iframepage"))

{

if (win && !window.opera)

{

if (win.contentDocument && win.contentDocument.body.offsetHeight) {

win.height = win.contentDocument.body.offsetHeight + 25;

}

else if(win.Document && win.Document.body.scrollHeight) {

win.height = win.Document.body.scrollHeight + 25;

}

}

}

}

function IFrameReSizeWidth(obj) {

var win=obj;

if (document.getElementById("iframepage"))

{

if (win && !window.opera)

{

if (win.contentDocument && win.contentDocument.body.offsetWidth) {

win.width = win.contentDocument.body.offsetWidth;

} else if(win.Document && win.Document.body.scrollWidth) {

win.width = win.Document.body.scrollWidth;

}

}

}

}

2.在iframe页面中用js操作父窗体的内容

window.parent.document.getElementById('mulufirst').innerHTML=$(this).text();

3.iframe中的链接在父窗体中不出现”画中画“,即怎样操作它的类似于target的属性:在location前加上window.top/parent/blank.....等,假设是单纯的标签,直接设置target属性就可以。

搜索答案

$(function() {

var searchKey = $("#searchAsk");

$("#searchAnswer")

.click(

function() {

if (searchKey.val() == ""

|| searchKey.val() == "请输入你的问题?") {

window.top.location.href = "http://baidu.com";

} else {

var asktitle = escape(searchKey.val());

window.top.location.href = "http://hao123.com?key=121";

}

});

假设须要设成_blank属性的话,不能直接用window.blank.location.href

window.top.location.href = "http://baidu.com";

window.open("http://baidu.com","_blank");

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值