用Request方法从页面得到Html内容时的处理 及 iframe中控件内容的获取
Posted on 2006-04-14 17:15 山西.net俱乐部 阅读(249) 评论(2) 编辑 收藏 引用 网摘 所属分类: 代码人生
1.用request方法从页面取得数据若包含html格式数据,则会提示出错,解决方法为:在web.config中<system.web>中增加<pages validateRequest="false"></pages>即可
2. 若页面使用了iframe,若要获得iframe中的控件内容,如下:
editor 为一frame的ID,Composition为editor中包含的另一frame的ID,
document.frames("editor").frames("Composition").document.body.innerHTML;
一般使用在新闻或文字类的编辑功能中,此时,在页面增加一隐藏的input控件,然后在iframe中增加事件,最后在后台通过request获取隐藏控件的值即可。
隐藏的控件:
2. 若页面使用了iframe,若要获得iframe中的控件内容,如下:
editor 为一frame的ID,Composition为editor中包含的另一frame的ID,
document.frames("editor").frames("Composition").document.body.innerHTML;
一般使用在新闻或文字类的编辑功能中,此时,在页面增加一隐藏的input控件,然后在iframe中增加事件,最后在后台通过request获取隐藏控件的值即可。
隐藏的控件:
<
input id
=
"
WebEditor1
"
type
=
"
hidden
"
name
=
"
WebEditor1
"
>
iframe:
1
<
iframe id
=
"
editor
"
onblur
=
"
WebEditor1_CopyEditContent();
"
style
=
"
WIDTH: 98.19%; HEIGHT: 344px
"
2 name = " myEditor " src = " ../OperateWord/editor.htm " width = " 98% " height = " 300 " ></ iframe >
2 name = " myEditor " src = " ../OperateWord/editor.htm " width = " 98% " height = " 300 " ></ iframe >
<
script language
=
"
javascript
"
>
function WebEditor1_CopyEditContent()
{
//document.getElementById('WebEditor1').value = editor.document.body.innerHTML;
//document.getElementById('WebEditor1').value = document.frames("editor").frames("Composition").document.body.innerText;
document.getElementById('WebEditor1').value = document.frames("editor").frames("Composition").document.body.innerHTML;
//}
}
</ script >
function WebEditor1_CopyEditContent()
{
//document.getElementById('WebEditor1').value = editor.document.body.innerHTML;
//document.getElementById('WebEditor1').value = document.frames("editor").frames("Composition").document.body.innerText;
document.getElementById('WebEditor1').value = document.frames("editor").frames("Composition").document.body.innerHTML;
//}
}
</ script >
后台取值:Request["WebEditor1"].ToString()