jquery - 我们如何在 mht 文件中使用 JQuery?

标签 jquery firefox cognos cognos-10 mhtml

我在 cognos 中生成了一些事件报告。然后我在 Cognos 中使用 JQuery 得到了这个动态报告: http://www.ibm.com/developerworks/library/ba-pp-reporting-advanced-report-design-page647/

我用 JQuery 生成了一些交互式报告。但现在我想使用 JQuery 生成一个事件报告。我尝试过,但没有成功。那么有没有办法在 mht 文件中使用 JQuery 呢? (因为事件报告以该格式存储)。

这是我在report studio中的HTML项目中获取的代码:

<script type="text/javascript">
var j = jQuery.noConflict();
j(document).ready(function()
{
  alert("hello");
  j('.ShowHideMap').hide();
  j('.ShowHideClicker').click(function()
  {
    j(this).next().toggle();
  });
});
</script>

<div class="ShowHideClicker">Click here to show/hide the Map Report</div>
<div class="ShowHideMap">
  
  Map comes here
  
</div>  

我正在使用 Firefox 打开事件报告。当我打开报告并单击“单击此处显示/隐藏 map 报告”时,它并没有隐藏。

我拿了一个记事本并输入以下代码并将其另存为“test.mht”

<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" 
  src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery-ui.min.js"></script>
<script type="text/javascript">
var j = jQuery.noConflict();
j(document).ready(function()
{
  j('.ShowHideMap').hide();
  j('.ShowHideClicker').click(function()
  {
    j(this).next().toggle();
  });
});
</script>
</head>
<body>
<div class="ShowHideClicker">Click here to show/hide the Map Report</div>
<div class="ShowHideMap">
Map
</div>
</body>
</html>

它成功了。当我单击“单击此处显示/隐藏 map 报告”时,“ map ”一词正在显示/隐藏。但是,当我在事件报告中的 HTML 项目中采用相同的代码时,报告不会显示/隐藏。

最佳答案

这可能有帮助

https://bobsbiblog.wordpress.com/2014/08/25/creating-javascript-functions-in-active-reports/

该技术的关键是标签,它是少数几个包含 onLoad 事件的标签之一。该事件在图像显示后立即触发。

在报表上的任意位置添加 HTML 项目,只需确保它位于始终会呈现的位置(在页面上,但不在任何面板内)。为 HTML 项目提供以下文本:

<img src="hal/imagesirot/progress.gif" width="1" height="1" onload="
     while( ! alert) {} 
     /* Define the function */ 
     if (!document.testFunction ) { 
          testFunction = function() { 
               alert('We are running the test function'); 
          } 
     } 
     /* Run any startup actions */ 
     testFunction(); 
"/>

关于jquery - 我们如何在 mht 文件中使用 JQuery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30076901/

相关文章:

javascript - 返回按钮导致 iFrame 延迟 window.onLoad 事件

cognos - 如何在 Cognos 查询表达式中获取当前日期?

javascript - Cognos 11.0.11 - Javascript 显示/隐藏日期提示

mysql - IBM Cognos _days_between 函数不起作用

javascript - 如何在 jQuery mobile 中显示 XML 中的图像?

jQuery 滚动条间距问题

php - jquery完整日历在ipad safari浏览器上不显示事件

用于切换显示/隐藏侧边栏的 jQuery 插件

javascript - Firefox 可以检测 MetaKey 吗?

javascript - CSS 先于 JS,Firefox 中出现白色闪烁?