历史版本4 :借用浏览器功能写JS语句 返回文档
编辑时间: 内容长度:图片数:目录数: 修改原因:

目录:

1. 问题描述编辑

帆软很多个性化功能的实现,都需要使用js来控制。

我们如何能零基础写js控制呢?

2. 示例编辑

借用论坛一个实例来讲解下如何用浏览器功能快速编辑js语句。

示例要求:

通过按钮的js脚本来触发弹出一个“对话框”方式的页面。

准备工作:

1、google浏览器、360浏览器或其它具有审查元素功能的浏览器。

2、帆软设计器。

3. 解决方案编辑

目前的已知条件是:

1、我们知道,帆软的超链接功能是提供“对话框”方式网页弹出方式的。

2、我们不知道,如何在按钮中,来实现“对话”框方式网页的弹出。

那么。我们开始进行如下操作!

3.1 添加超级链接

我们先做一个"对话框”方式网页弹出方式的超级链接。

选中A1单元格,右键选择“超级链接”菜单,如下图所示:
222
添加一个网络报表,任意选择一个模板,如GettingStarted.cpt,链接打开于对话框,如下图所示:
222

3.2 进行分页预览

保存后,点击分页预览,效果如下:
222

3.3 查看元素代码

按下浏览器的F12或是右键选择“审查元素”就可以看到网页各个元素的代码了。

222

我们通过浏览器的标识一步一步的找到这个超链对应的代码,并复制所查找到的代码。
222

得到如下代码:

<span class="linkspan" style="cursor:pointer;" onclick="FR.doHyperlink(event||window.event, [{&quot;data&quot;:&quot;var as=arguments; return FR.tc(function(){FR.doHyperlinkByGet4Reportlet({\&quot;para\&quot;:{\&quot;__pi__\&quot;:true},\&quot;feature\&quot;:\&quot;width=600,height=400,\&quot;,\&quot;title\&quot;:\&quot;网络报表1\&quot;,\&quot;url\&quot;:\&quot;/WebReport/ReportServer?reportlet=%2FGettingStarted.cpt\&quot;,\&quot;target\&quot;:\&quot;_dialog\&quot;})}, this, as)&quot;,&quot;name&quot;:&quot;网络报表1&quot;}], true)">测试用超级链接</span>
3.4 整理所得代码

对上述代码进行整理,将onclick动作需要执行的部分复制出来。

FR.doHyperlink(event||window.event, [{&quot;data&quot;:&quot;var as=arguments; return FR.tc(function(){FR.doHyperlinkByGet4Reportlet({\&quot;para\&quot;:{\&quot;__pi__\&quot;:true},\&quot;feature\&quot;:\&quot;width=600,height=400,\&quot;,\&quot;title\&quot;:\&quot;网络报表1\&quot;,\&quot;url\&quot;:\&quot;/WebReport/ReportServer?reportlet=%2FGettingStarted.cpt\&quot;,\&quot;target\&quot;:\&quot;_dialog\&quot;})}, this, as)&quot;,&quot;name&quot;:&quot;网络报表1&quot;}], true)

3.5 对浏览器代码进行转义

由于浏览器解析需要,会将“双引号”转义为“&quot;”,我们需要替换回来。得到代码:

FR.doHyperlink(event||window.event, [{"data":"var as=arguments; return FR.tc(function(){FR.doHyperlinkByGet4Reportlet({\"para\":{\"__pi__\":true},\"feature\":\"width=600,height=400,\",\"title\":\"网络报表1\",\"url\":\"/WebReport/ReportServer?reportlet=%2FGettingStarted.cpt\",\"target\":\"_dialog\"})}, this, as)","name":"网络报表1"}], true)

个别浏览器预览会报错:event is not defined

这时需要把event||删掉就可以了,得到最终代码:

FR.doHyperlink(window.event, [{"data":"var as=arguments; return FR.tc(function(){FR.doHyperlinkByGet4Reportlet({\"para\":{\"__pi__\":true},\"feature\":\"width=600,height=400,\",\"title\":\"网络报表1\",\"url\":\"/WebReport/ReportServer?reportlet=%2FGettingStarted.cpt\",\"target\":\"_dialog\"})}, this, as)","name":"网络报表1"}], true)
3.6 添加按钮控件

把这个代码放到按钮控件中的js里。就可以实现最终效果了。点击按钮,也可实现超级链接弹出对话框的效果。
222