随笔 - 15  文章 - 0  评论 - 1  阅读 - 14983

帆软用工具测试超链接打开弹窗(iframe嵌套),解决js传参带中文传递有乱码问题

1、新建超链接

随意点击一个单元格右击,选择 超级链接 

2、在弹出的窗口中选择JavaScript脚本 如图:

其中红框框出的是几个要点   ,左边的就不讲了,右上角的参数cc是设置了公式remoteServletURL  能自动获取报表路径 如图:

右下角的js代码是设置一个iframe弹窗,代码如下:

复制代码
1 var url =FR.cjkEncode("?formlet=indicatorDetailedTypeFirst.frm&companycode=0102010101&intermediarycode=0201072911&name=赵振强");
2 var iframe = $("<iframe id='inp' name='inp' width='100%' height='100%' scrolling='yes' frameborder='0'>"); // 对话框内 iframe 参数的命名,默认宽高占比是 100%,可向下滚动    
3 iframe.attr("src", cc+url);
4 //iframe.attr("src", cc+"?formlet=indicatorDetailedTypeFirst.frm&name=赵振强"); // 给 iframe 添加 src 属性  
5 var o = {    
6 width : 700,  //对话框宽度  
7 height: 500  //对话框高度  
8 };    
9 FR.showDialog("添加", o.width, o.height, iframe,o);//弹出对话框
复制代码

其中需要注意的是如果参数中有 中文需要将url包裹在编码FR.cjkEncode()里,否则传参中的中文将会是乱码:如图

 

 

需要注意的是:如果放到工程js中会报FR没定义,我找了半天没找到怎么引入帆软的js,网上百度看到有人贴出了cjkEncode的源码,直接加到js方法中调用即可

复制代码
$.GPageModule([""],function(){
    var modelType = "indicatorDetailedTypeFirst.frm";
    var companycode = $("#companycode").val();
    var intermediarycode =$("#intermediarycode").val();
    var name =$("#name").val();
    var reportURL = cjkEncodeNew(GlobalParam.context+"/ReportServer?formlet=erm/sj/"+modelType+"&companycode="+companycode+"&intermediarycode="+intermediarycode+"&name="+name);
    $("#viewIndicatorDetailedType").attr("src",reportURL);
});

function cjkEncodeNew(text) {
    if (text == null) {
        return "";
    }
    var newText = "";
    for (var i = 0; i < text.length; i++) {
        var code = text.charCodeAt (i);
        if (code >= 128 || code == 91 || code == 93) {//91 is "[", 93 is "]".
            newText += "[" + code.toString(16) + "]";
        } else {
            newText += text.charAt(i);
        }
    }
    return newText;
}
复制代码

 

 原创总结。

posted on   宇宙小子  阅读(2140)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示