【问题标题】:popup applet does not render the second click in the window that calls弹出小程序不会在调用的窗口中呈现第二次单击
【发布时间】:2011-05-20 12:58:41
【问题描述】:

我正在使用 struts 和一个我使用的在 jsp 中调用的小程序进行 Web 开发。当我第一次单击时,弹出窗口完美显示,当我第二次单击调用小程序的按钮时,我的小程序窗口不呈现,仅显示背景。当我尝试 F5 时,它可以工作。

此问题仅在 Firefox 中出现。我如何解决这个问题?

这是我的点击:

onClick="javascript:showPopupAssinatura('<c:url value="/jsp/servidor/tabletAssinaturaManuscrita.jsp"/>', 'PopupAjuda', 633, 349, 'status=0,scrollbars=0, resizable=no');"

这是我的函数 showPopupAssinatura:

function showPopupAssinatura(mypage,myname,w,h,features) {
if(screen.width){
     var winl = (screen.width-w)/2;
     var wint = (screen.height-h)/2;
     }else{winl = 0;wint =0;}
     if (winl < 0) winl = 0;
     if (wint < 0) wint = 0;
     var settings = 'height=' + h + ',';
     settings += 'width=' + w + ',';
     settings += 'top=' + wint + ',';
     settings += 'left=' + winl + ',';
     settings += features;
     var target = "mppesga" + myname;
     win = window.open(mypage,target,settings);

     if (win != null) {
        win.window.focus();
 }
}

【问题讨论】:

  • 我尝试使用 win.focus() 但它不起作用 =/

标签: jsp applet popup onclick


【解决方案1】:

我使用 javascript 方法解决了这个问题:showModalDialog !!!

function showPopupAssinatura(mypage,myname,w,h,features) {
if(screen.width){
     var winl = (screen.width-w)/2 - 66;
     var wint = (screen.height-h)/2 + 26;
     var navegador = navigator.appName.toLowerCase();

}else{winl = 0;wint =0;}

     if (winl < 0) winl = 0;
     if (wint < 0) wint = 0;

     var settings = 'height=' + h + ',';
     settings += 'width=' + w + ',';
     settings += 'top=' + wint + ',';
     settings += 'left=' + winl + ',';
     settings += features;
     var target = "mppesga" + myname;

     /** 

      * checking what browser is currently being used to make the action of  
      * visualize the popup. 
      */

     if(navegador.indexOf("netscape") != -1)
         win = window.showModalDialog(mypage,null,"dialogWidth:"+w+"; dialogHeight:"+(h+=6)+"; dialogTop:"+wint+"; dialogLeft:"+winl+"; resizable:no");
     else
         win = window.open(mypage,target,settings);

     if (win != null) {
        win.window.focus();
 }
}

此解决方案仅适用于 Firefox,因为在 IE 中,大小超出标准,因此,我为当前使用的浏览器设置了条件。

如果这段代码遇到同样的问题,我希望我能帮助别人。 =]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-30
    • 1970-01-01
    • 2012-09-02
    相关资源
    最近更新 更多