WEB在模态窗体里导出或下载文件功能代码
程序员文章站
2024-03-02 18:14:22
复制代码 代码如下: 我的聊天记录
<title>我的聊天记录</title>
<base target="_self" />
<script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$('a[href][href!="#"]').click(function() {
setselftarget(this);
});
$('input').click(function() {
setselftarget(this);
});
});
function settarget() {
var htmtarget = document.getelementsbytagname("head");
if ((undefined != htmtarget) && (0 < htmtarget.length)) {
var b = htmtarget[0].getelementsbytagname("base");
if ((undefined != b) && (0 < b.length)) {
b[0].target = "download";
}
}
}
function setselftarget(obj) {
if (obj.id != "btn_export") {
var htmtarget = document.getelementsbytagname("head");
if ((undefined != htmtarget) && (0 < htmtarget.length)) {
var b = htmtarget[0].getelementsbytagname("base");
if ((undefined != b) && (0 < b.length))
b[0].target = "_self";
}
}
}
</script>
<asp:button id="btn_export" runat="server" text="导出" onclick="btn_export_click" onclientclick="settarget()" />
复制代码 代码如下:
<title>我的聊天记录</title>
<base target="_self" />
<script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$('a[href][href!="#"]').click(function() {
setselftarget(this);
});
$('input').click(function() {
setselftarget(this);
});
});
function settarget() {
var htmtarget = document.getelementsbytagname("head");
if ((undefined != htmtarget) && (0 < htmtarget.length)) {
var b = htmtarget[0].getelementsbytagname("base");
if ((undefined != b) && (0 < b.length)) {
b[0].target = "download";
}
}
}
function setselftarget(obj) {
if (obj.id != "btn_export") {
var htmtarget = document.getelementsbytagname("head");
if ((undefined != htmtarget) && (0 < htmtarget.length)) {
var b = htmtarget[0].getelementsbytagname("base");
if ((undefined != b) && (0 < b.length))
b[0].target = "_self";
}
}
}
</script>
<asp:button id="btn_export" runat="server" text="导出" onclick="btn_export_click" onclientclick="settarget()" />