开发者

JSF JavaScript problem - "jsf" is undefined

开发者 https://www.devze.com 2023-02-08 17:51 出处:网络
my webapplication works very fine with: Opera, FF, Chrome, Safari. Now i tested it on IE and there are some weird errors.

my webapplication works very fine with: Opera, FF, Chrome, Safari. Now i tested it on IE and there are some weird errors. I debugged my website with IE and it said:

<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 ).

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:ou开发者_如何学运维tputScript name="jsf.js" library="javax.faces" target="head" />
...

I think the identified "jsf" is available in jsf.js. Why does IE return this error?

These are just simple commandbuttons/links created with JSF tags:

Did I miss anything? Why does it work on all browsers except IE? Unfortunately I didnt find any hints on google.

Regards Johnny


do you have a DOM element with the id set to "jsf"? 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.

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.

More on that in the link below: http://www.west-wind.com/weblog/posts/2009/Mar/22/Internet-Explorer-Global-Variable-Blow-ups


Place the JSF js declaration in the top of the JS declarations also surround these with h:head tag so I suggest changing to:

<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">
0

精彩评论

暂无评论...
验证码 换一张
取 消