2015年6月6日 星期六

有人能幫我解決showModalDialog問題

好多年前寫了套網上會計軟件, 使用了javascript showModalDialog 來取會計帳戶編號, 但新版的Google Chrome不支援這function, 有人能幫我解決嗎? 以下是查看問題的步驟.


可先下載網上會計軟件 (http://www.memdb.com/download/MemAccWeb.exe), 安裝後按[伺服器設定], 預設WEB SERVER PORT是80, 按下[開啟伺服器], 成功應該可以在IE上登入, 編號是admin, 密碼是memdb.

登入後可以看到MENU, 按[傳票管理], 再按[加入傳票], 就能看到下圖:

Picture

如在IE按[...], 就能列出傳票讓用戶選擇帳戶, 或在帳戶編號輸入編號1210, 按[...] 就能自動選擇帳戶. 以上功能在IE完成沒問題.

但如在Google Chrome按[...]就不成功 (因為新版不支援showModalDialog), 它會CALL在安裝Folder內voucher.js中以下FUNCION:


function getAccCat(row,type)
{
   alert("START");
   var r;
   var w = window.screen.availWidth-50;
   var h = window.screen.availHeight-50;
   if(inputForm['accCode'+row].value=='')
      r = showModalDialog('?page=selectAccCat&type='+type, inputForm['accName'+row], 'status=0;resizable=1;scrollbars=1;dialogWidth=' + w + 'px;dialogHeight=' + h +'px;');
   else
      r = showModalDialog('?page=selectAccCat&accCode='+inputForm['accCode'+row].value, inputForm['accName'+row], 'status=0;resizable=1;scrollbars=1;dialogWidth=' + w + ';dialogHeight=' + h +';');
   alert(r);
...


alert 是我後加的, 如alert(r)能出1210就成功, 不知以上問題有沒有人可以幫我 (當然IE和CHROME都能用), 如需要費用, 可向我提出.

36 則留言:

  1. http://blog.163.com/zhi_qingfang@126/blog/static/11747756320132218144825/

    回覆刪除
  2. weijen6 :
    http://blog.163.com/zhi_qingfang@126/blog/static/11747756320132218144825/



    這我之前google過,但是都不能成功。

    回覆刪除
  3. http://stackoverflow.com/a/28842258

    回覆刪除
  4. Tam :
    http://stackoverflow.com/a/28842258

    謝謝, 但因為我十年沒有寫JAVASCRIPT, 而且我不會發展JAVASCRIPT, 想找人跟和升級這軟件和替MEMDB發展WEB APP, 這是提出這問題的目的.
    有人願意花些時間去了解個voucher.js (這個是我十前前寫的, 現在已忘了如何寫了), 和更新這檔案, 令這軟件能繼續支援IE和CHROME嗎?

    回覆刪除
  5. weijen6 :
    http://blog.163.com/zhi_qingfang@126/blog/static/11747756320132218144825/

    最新版的CHROME, 己不支援, 如我行
    var returnValue = window.showModalDialog("login.html ", window);
    都沒有SHOW個DIALOG了.

    回覆刪除
  6. http://demo.agektmr.com/dialog/

    回覆刪除
  7. https://github.com/niutech/showModalDialog
    http://blog.bossma.cn/javascript/chrome-not-surpport-showmodaldialog-solution/

    回覆刪除
  8. weijen6 :
    http://demo.agektmr.com/dialog/

    謝謝, 我想這是解決方案, 但我想請人幫手直接改 voucher.js, 他負責HTML5, 我可協助改個程式 (或遲些可以把程式都交給他), 因為始終要下放些工作下去.

    回覆刪除
  9. YY :
    Tam :
    http://stackoverflow.com/a/28842258
    謝謝, 但因為我十年沒有寫JAVASCRIPT, 而且我不會發展JAVASCRIPT, 想找人跟和升級這軟件和替MEMDB發展WEB APP, 這是提出這問題的目的.
    有人願意花些時間去了解個voucher.js (這個是我十前前寫的, 現在...

    回覆刪除
  10. YY :
    Tam :
    http://stackoverflow.com/a/28842258
    謝謝, 但因為我十年沒有寫JAVASCRIPT, 而且我不會發展JAVASCRIPT, 想找人跟和升級這軟件和替MEMDB發展WEB APP, 這是提出這問題的目的.
    有人願意花些時間去了解個voucher.js (這個是我十前前寫的, 現在...

    If you've fixed the problem so just neglect it.
    I've tried a .js file and seems it overcomes some aspects of your case. And I guess, need to modify your popup dialog to fix all the things.
    https://drive.google.com/file/d/0By1mGveElQkZMnBHa2s2RkYtcHc/view?usp=sharing
    Added one line to voucher.js to include the showModalDialog.js
    The demo-modal.html is just for testing the return value. It works to get back return value but for your popup dialog, it failed. But it can get the text "現金" to the parent window. The close button of your dialog is also not work. In my new dialog box, top right corner it has the "cross" sign for close the dialog (dialog.close)

    回覆刪除
  11. B :
    YY :
    Tam :
    http://stackoverflow.com/a/28842258
    謝謝, 但因為我十年沒有寫JAVASCRIPT, 而且我不會發展JAVASCRIPT, 想找人跟和升級這軟件和替MEMDB發展WEB APP, 這是提出這問題的目的...

    with better dialog size version:
    https://drive.google.com/file/d/0By1mGveElQkZdko3aWVpdHF0bEE/view?usp=sharing

    回覆刪除
  12. B :
    B :
    YY :Tam :http://stackoverflow.com/a/28842258謝謝, 但因為我十年沒有寫JAVASCRIPT, 而且我不會發展JAVASCRIPT, 想找人跟和升級這軟件和替MEMDB發展WEB APP, 這是提出這問題的目的...
    with better dialog size version:
    https://drive.google.com/...

    Thank you B, i have found and tried that showModalDialog.js before but failed to make it pop-up. And now you help me to fix this pop-up problem. I will try to fix the select and close problem. Can you whatsapp me 93225064 and keep contact with me? I am looking for any chance to co-operate with you.

    回覆刪除
  13. When the user selec the account, it will call:
    function selectAccCat(accName,accCode)
    {
    window.dialogArguments.value=accName;
    window.returnValue=accCode;
    window.close();
    }
    however if i change window.close to dialog.close, it still not work for Chrome (and also not working on IE)

    回覆刪除
  14. 另外, 長遠是否用HTML5的 dialog tag會好過用那個showModalDialog.js呢?

    回覆刪除
  15. If you are interested in, u can send me email info5@memdb.com, i can send you the source code of selectAccCat to investigate.

    回覆刪除
  16. How to replace
    onClick=window.close()
    to close the window, i change to:
    onClick=dialog.close()
    But fail, i guess it is because 'dialog' is not defined.

    回覆刪除
  17. YY :
    B :
    B :
    YY :Tam :http://stackoverflow.com/a/28842258謝謝, 但因為我十年沒有寫JAVASCRIPT, 而且我不會發展JAVASCRIPT, 想找人跟和升級這軟件和替MEMDB發展WEB APP, 這是提出這問題的目的...
    with better dialog size v...

    https://drive.google.com/file/d/0By1mGveElQkZZndJMDhLV3d3Rkk/view?usp=sharing
    please try this version. Added one line to showModalDialog.js to give the dialog an ID. My dialog demo html is with a workable close button.

    回覆刪除
  18. YY :
    另外, 長遠是否用HTML5的 dialog tag會好過用那個showModalDialog.js呢?



    showModalDialog.js 就係 dynamic generate 個 html5 dialog tag

    回覆刪除
  19. Thank you B.
    I change
    window.close() to
    parent.document.getElementById('dialogModal').close();
    It work in chrome, but fail in IE.
    Also, the window.returnValue=accCode;
    cannot return the value to the parent in chrome.

    回覆刪除
  20. YY :
    Thank you B.
    I change
    window.close() to
    parent.document.getElementById('dialogModal').close();
    It work in chrome, but fail in IE.
    Also, the window.returnValue=accCo...

    Because showModalDialog.js would use only if the browser supports showModalDialog, so u should use :
    if (window.showModalDialog)
    {
    window.close();
    }
    else
    {
    parent.document.getElementById('dialogModal').close();
    }

    回覆刪除
  21. YY :
    Thank you B.
    I change
    window.close() to
    parent.document.getElementById('dialogModal').close();
    It work in chrome, but fail in IE.
    Also, the window.returnValue=accCo...

    Because showModalDialog.js would use <dialog> only if the browser supports showModalDialog, so u should use :
    if (window.showModalDialog)
    {
    window.close();
    }
    else
    {
    parent.document.getElementById('dialogModal').close();
    }

    回覆刪除
  22. YY :
    Thank you B.
    I change
    window.close() to
    parent.document.getElementById('dialogModal').close();
    It work in chrome, but fail in IE.
    Also, the window.returnValue=accCo...

    我開頭試,見佢個帳戶名稱傳得翻上 parent,所以我估個編號都應該得,但係我冇 code 睇唔倒,咁不如你俾 "建立傳票" 同 "帳戶選擇" 嘅 html 我望望,thx.

    回覆刪除
  23. B :
    YY :
    Thank you B.
    I change
    window.close() to
    parent.document.getElementById('dialogModal').close();
    It work in chrome, but fail i...

    Sorry, I mean :
    Because showModalDialog.js would use only if the browser doesn't support showModalDialog

    回覆刪除
  24. B :
    YY :
    Thank you B.
    I change
    window.close() to
    parent.document.getElementById('dialogModal').close();
    It work in chrome, but fail i...

    Sorry, I mean :
    Because showModalDialog.js would use <dialog> only if the browser doesn't support showModalDialog

    回覆刪除
  25. https://drive.google.com/file/d/0By1mGveElQkZdFZGLVg3VjZOZTA/view?usp=sharing
    updated selectAccCat.
    ok to close for both ie and chrome.
    accName ok for both as before.
    only accCode failed.
    because window.returnValue doesn't work for chrome now.
    I would try to fix it later.

    回覆刪除
  26. B :
    YY :
    Thank you B.I changewindow.close() toparent.document.getElementById('dialogModal').close();It work in chrome, but fail in IE.Also, the window.returnValue=accCo...
    我開頭試,見佢個帳戶名稱傳得翻上 parent,所...

    You can see the HTML source in IE, or change the document.oncontextmenu= ContextMenu; in common.js

    回覆刪除
  27. YY :
    B :
    YY :
    Thank you B.I changewindow.close() toparent.document.getElementById('dialogModal').close();It work in chrome, but fail in IE.Also, the window.returnValue=...

    u've hardcoded to control the context menu and it can't be controlled by common.js
    So I use alert to show the innerHTML.

    回覆刪除
  28. B :
    https://drive.google.com/file/d/0By1mGveElQkZdFZGLVg3VjZOZTA/view?usp=sharing
    updated selectAccCat.
    ok to close for both ie and chrome.
    accName ok for both as befor...

    https://drive.google.com/file/d/0By1mGveElQkZZnkzX0VGbGFqRzA/view?usp=sharing
    updated voucher.js, showModalDialog to use dialogArguments to transfer both accCode and accName to the parent window. Really no way to transfer by returnValue. Seems need to rewrite all the related parts.

    回覆刪除
  29. Thank you a lot, yes, it still needs to change a lot. For example, I put arlert after showModalDialog and it will not run.
    r = showModalDialog(...);
    alert(r);
    That cause a problem when selecting the account, if I click [收入] in tab, it will not let me to select account in [收入], secondly, it will not setfocus on the "description" field.

    回覆刪除
  30. YY :
    Thank you a lot, yes, it still needs to change a lot. For example, I put arlert after showModalDialog and it will not run.
    r = showModalDialog(...);
    alert(r);
    Th...

    alert(r) will not run is due to the last line (throw;) of showModalDialog.js
    It's ok to run anything if u remarked that line.
    The returnValue doesn't work because the dialog tag is generated dynamically.
    And the relationship of showModalDialog to the parent window is totally different to the dialog tag and the parent window.
    For transfer the values between them can be implemented by the dialogArguments. But all the things related to returnValue must be rewrite for chrome.

    回覆刪除
  31. YY :
    Thank you a lot, yes, it still needs to change a lot. For example, I put arlert after showModalDialog and it will not run.
    r = showModalDialog(...);
    alert(r);
    Th...

    alert(r) will not run is due to the last line (throw;) of showModalDialog.js
    It's ok to run anything if u remarked that line.
    The returnValue doesn't work because the dialog tag is generated dynamically.
    And the relationship of showModalDialog to the parent window is totally different to the dialog tag and the parent window.
    For transfer the values between them can be implemented by the dialogArguments. But all the things related to returnValue must be rewrited for chrome, although it should be easy.

    回覆刪除
  32. B :
    YY :
    Thank you a lot, yes, it still needs to change a lot. For example, I put arlert after showModalDialog and it will not run.r = showModalDialog(...);alert(r);Th...
    alert(r) will not run is d...

    Thank you B.
    I have tried it but still fail (for changing tabs 收入, 支出. I think we may need to spend more time on it.
    Do you still want to try? Or anyway we can co-opearte to fix it more efficiently? Or email me to discuss? info5@memdb.com

    回覆刪除
  33. Here is what I did:
    http://www.memdb.com/download/MemAccWeb2.exe
    I need two feactures:
    1) After I select the account 1220, it will focus on the 摘要 fields.
    2) If I click [收入] tab (it will call selectAccCat("收入",4), it will show all 收入 account for me, and I can select 4100
    I have change to call dialogClose when user click [關閉].
    If you need source code of the ?page=selectAccCat&type='+type, email to me, I can send it for you.
    Really thank you for helping me.

    回覆刪除
  34. B :
    YY :
    Thank you a lot, yes, it still needs to change a lot. For example, I put arlert after showModalDialog and it will not run.r = showModalDialog(...);alert(r);Th...
    alert(r) will not run is d...

    Hi B, someone has helped me to fix it using iframe src. I remember you have emailed about yourselve before but sorry, I missed that email, can you re-email me again, I hope we can keep in touch and work together in future.

    回覆刪除
  35. YY :
    B :
    YY :
    Thank you a lot, yes, it still needs to change a lot. For example, I put arlert after showModalDialog and it will not run.r = showModalDialog(...);alert(r...

    good. iframe may be easy and better for your situation because the dom relationship is similar to the showModalDialog. I just try to use the html5 <dialog> to implement it.
    I can't remember if I've emailed u before and I should not know your email address. Anyway sure u're welcome to email me. I just coding for fun.

    回覆刪除
  36. B :
    YY :
    B :YY :Thank you a lot, yes, it still needs to change a lot. For example, I put arlert after showModalDialog and it will not run.r = showModalDialog(...);alert(r...
    good. iframe may be eas...

    Can you email to me (info5@memdb.com) and tell me more about you? I like making friends with those coding for fun. Thank you your help.

    回覆刪除