简体   繁体   English

按下与target =“ _ blank”的commandLink后,页面在Chrome中变为“冻结”状态

[英]Page becomes 'frozen' in Chrome after commandLink with target=“_blank” is pressed

Here is jsf code: 这是jsf代码:

<h:commandLink id="previewlink" value="#{msg['report.preview']}" target="_blanc">
    <f:param name="printpreview" value="#{previewTitle}"/>
</h:commandLink>

When I press the link new page is opened in a new tab and works fine but parent page becomes blocked (ie none of its commandLinks work). 当我按下链接时,新页面将在新选项卡中打开,并且可以正常工作,但是父页面被阻止(即,其commandLinks均不起作用)。 In Firefox everything works fine on both pages. 在Firefox中,两个页面上的所有内容均正常运行。

Any suggestions? 有什么建议么?

UPD: source in img (can't find text version in chrome) UPD:img中的源代码(无法在Chrome中找到文本版本)

alt text http://img402.imageshack.us/img402/2127/source.png 替代文字http://img402.imageshack.us/img402/2127/source.png

Looking at the generated JavaScript function, you're using Sun Mojarra as JSF implementation (please mention that with more detail in the future, you could for instance also have used Apache MyFaces). 查看生成的JavaScript函数,您将Sun Mojarra用作JSF实现(请注意,将来有更多详细信息,例如,您可能还使用了Apache MyFaces)。

I just tried the following SSCCE on Tomcat 6.0.20 with Mojarra 1.2_14: 我刚刚在Mojarra 1.2_14的Tomcat 6.0.20上尝试了以下SSCCE:

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<f:view>
    <html>
        <head>
            <title>SO question 2111438</title>
        </head>
        <body>
            <h:form id="form">
                <h:commandLink id="link" value="link" action="#{bean.action}" target="_blank">
                    <f:param name="paramname" value="paramvalue" />
                </h:commandLink>
            </h:form>
        </body>
    </html>
</f:view>

...with a dummy action method on a request scoped bean and it just works flawlessly on Chrome 3.0.195.38. ...在请求范围内的bean上使用虚拟操作方法,它在Chrome 3.0.195.38上可以完美运行。

I however recall similar JavaScript problem with Safari which has been fixed about around Mojarra 1.2_08. 但是,我回想起与Safari类似的JavaScript问题,该问题已在Mojarra 1.2_08周围解决。 Ensure that you're using the latest Mojarra version. 确保您使用的是最新的Mojarra版本。 You can get it at their main dev site . 您可以在他们的主要开发站点上获得它。 Hope this helps. 希望这可以帮助。

The full generated HTML source was by the way (slightly reformatted): 完整生成的HTML源代码是(稍微重新格式化)的:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

<html> 
    <head> 
        <title>SO question 2111438</title> 
    </head> 
    <body> 
        <form id="form" name="form" method="post" action="/playground/test.jsf" enctype="application/x-www-form-urlencoded"> 
            <input type="hidden" name="form" value="form" /> 
            <script type="text/javascript" language="Javascript">function dpf(f) {var adp = f.adp;if (adp != null) {for (var i = 0;i < adp.length;i++) {f.removeChild(adp[i]);}}};function apf(f, pvp) {var adp = new Array();f.adp = adp;var i = 0;for (k in pvp) {var p = document.createElement("input");p.type = "hidden";p.name = k;p.value = pvp[k];f.appendChild(p);adp[i++] = p;}};function jsfcljs(f, pvp, t) {apf(f, pvp);var ft = f.target;if (t) {f.target = t;}f.submit();f.target = ft;dpf(f);};</script> 
            <a id="form:link" href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('form'),{'form:link':'form:link','paramname':'paramvalue'},'_blank');}return false">link</a><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id8:j_id9" /> 
        </form>
    </body> 
</html>

The target="" attribute is used for frames only or with HTML 4.01 target =“”属性仅用于框架或与HTML 4.01一起使用

There is famous problem with google chrome in this area. 谷歌浏览器在该区域存在一个著名的问题。

Please try maybe with javascript - jQuery to have better cross browser compatibility. 请尝试使用javascript-jQuery,以获得更好的跨浏览器兼容性。

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

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