简体   繁体   English

JSF JavaScript问题 - “jsf”未定义

[英]JSF JavaScript problem - “jsf” is undefined

my webapplication works very fine with: Opera, FF, Chrome, Safari. 我的webapplication非常适用于:Opera,FF,Chrome,Safari。 Now i tested it on IE and there are some weird errors. 现在我在IE上测试它并且有一些奇怪的错误。 I debugged my website with IE and it said: 我用IE调试了我的网站,它说:

<a id="navi:searchButton" href="#" onclick="jsf.util.chain(this,event,'activateSearchDiv();return false;','mojarra.jsfcljs(document.getElementById(\'navi\'),{\'navi:searchButton\':\'navi:searchButton\'},\'\')');return false">Search</a>

>> "jsf" is not defined ( in jsf.util.chain ). >>“jsf”未定义(在jsf.util.chain中)。

But I do load these scripts: 但是我加载这些脚本:

<h:body>
    <f:view contentType="text/html">
        <h:outputScript library="js" name="chooseDevice.js" target="head" />
        <h:outputScript library="js" name="navigationScript.js" target="head" />
        <h:outputScript library="js" name="jquery.js" target="head" />
        <h:outputScript name="jsf.js" library="javax.faces" target="head" />
...

I think the identified "jsf" is available in jsf.js. 我认为在jsf.js中可以找到已识别的“jsf”。 Why does IE return this error? 为什么IE会返回此错误?

These are just simple commandbuttons/links created with JSF tags: 这些只是使用JSF标记创建的简单命令按钮/链接:

Did I miss anything? 我错过了什么吗? Why does it work on all browsers except IE? 为什么它适用于IE以外的所有浏览器? Unfortunately I didnt find any hints on google. 不幸的是,我没有在谷歌上找到任何提示。

Regards Johnny 关心约翰尼

Place the JSF js declaration in the top of the JS declarations also surround these with h:head tag so I suggest changing to: 将JSF js声明放在JS声明的顶部也用h:head标签包围这些声明,所以我建议改为:

<h:head>
   <h:outputScript name="jsf.js" library="javax.faces" target="head" />
   <h:outputScript library="js" name="jquery.js" target="head" />
   <h:outputScript library="js" name="chooseDevice.js" target="head" />
   <h:outputScript library="js" name="navigationScript.js" target="head" />
</h:head>
<h:body>
    <f:view contentType="text/html">

do you have a DOM element with the id set to "jsf"? 你有一个id为“jsf”的DOM元素吗? IE has a strange bug that happens when we try to use global variables which occurs to have the same name as a element's id. 当我们尝试使用与元素的id具有相同名称的全局变量时,IE会发生一个奇怪的错误。

if that's the case, you can predeclare the variable (put a " var varName; " in a script block in the top of the page) or just rename the element's id. 如果是这种情况,您可以预先声明变量(在页面顶部的脚本块中放置“ var varName; ”)或者只重命名元素的id。

More on that in the link below: http://www.west-wind.com/weblog/posts/2009/Mar/22/Internet-Explorer-Global-Variable-Blow-ups 更多相关链接如下: http//www.west-wind.com/weblog/posts/2009/Mar/22/Internet-Explorer-Global-Variable-Blow-ups

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM