0

I have a the following script as below.

$('.t1 span.droppable').each(function(){
                //alert("DROP");
                //$(this).droppable();
        $('.droppable').droppable({
    drop: function(event, ui) {


    var fromd = 0;
    var tod = 0;
    var url1 = "insertsw.php?fromd=" + fromd + "&tod=" + tod;
    var r = "";
    objArgs = new Array(tpFrom, sFrom, nsdFrom, tpTo,sTo, dTo);
    r=showModalDialog(url1,objArgs,"dialogWidth: 450; dialogHeight: 300; resizable: yes");

   if(r==null)
                {
                    popUpOpen=1;
                }
                else
                {
                    popUpOpen=1;
                //alert("R : "+r);
                var n=r.split("#");
                }
   }
 }
}

It have been working for almost 3 years on chrome and suddenly now it shows undefined. But works fine on firefox perfectly as usual. What changes have chrome done for me to adapt to it ?

user3953386
  • 153
  • 1
  • 2
  • 10

2 Answers2

0

Here's your issue: http://windowsitpro.com/blog/google-kills-showmodaldialog-api-chrome-37-and-does-evil-exchange-owa

Here are some workarounds: Why is window.showModalDialog deprecated? What to use instead?

EDIT:

take a look at this package: showModalDialog

You shouldn't need to change very much to get this package to work with yours. It's virtually the same syntax.

For example, you can do:

window.showModalDialog("demo-modal.html", "some arguments", "dialogWidth:500px;dialogHeight:200px");

Which is virtually the same as what you currently have. See if just including the package fixes it. I believe it should. There doesn't seem to be a different syntax at all, and this should work in chrome

Community
  • 1
  • 1
benderman
  • 103
  • 7
  • Ok I run this r = showModalDialog(url1,objArgs,""); but the error is still there only think the window now shrink – user3953386 Sep 16 '14 at 18:43
  • hmm, honestly i cant tell whats going on without more information, sorry – benderman Sep 16 '14 at 18:44
  • Ok benderman I removed this line throw 'Execution stopped until showModalDialog is closed'; and there is no error. But when I press the button Add I got this codes window.returnValue=Number(rFromControl.value)+"#"+Number(rToControl.value); window.close(); which now it does not close the window – user3953386 Sep 16 '14 at 18:54
  • what do you have a custom close button? or are you talking about the one in the top hand corner – benderman Sep 16 '14 at 18:56
  • I have custom close box which first I do a javascript validation all the fields have been filled then only finally I call this codes window.returnValue=Number(rFromControl.value)+"#"+Number(rToControl.value); window.close(); . Another thing I notice when I press the button I get this error now Uncaught SyntaxError: Unexpected token } referring to eval('{\n' + nextStmts.join('\n')); – user3953386 Sep 16 '14 at 19:01
  • You'll need to use jquery or document.getelemrnt to get the dialog and then call close on that element to close it – benderman Sep 16 '14 at 19:06
  • Do you mean something like this document.getelementByID("dialog").close(); How about passing by my return value ? – user3953386 Sep 16 '14 at 19:08
  • Put it in the parens for close – benderman Sep 16 '14 at 19:19
  • I have put this parent.document.getElementById("dialog").close();gives me cannot read property close. Another think in the pop-up window I have also include reference to javascript should I remove it or leave it? Lastly how to past back my pop-up value to my parent window – user3953386 Sep 16 '14 at 19:24
  • "Dialog" isn't it's id is it? Inspect the element on the page. You shouldn't need another reference to JavaScript I don't think. Not sure what you mean In the last question – benderman Sep 16 '14 at 19:28
  • I got this in the inspect element ×. So how to close on my custom button. what I mean by my last question is how to return this both values window.returnValue=Number(rFromControl.value)+"#"+Number(rToControl.value); – user3953386 Sep 16 '14 at 19:36
  • My problem now is to close using my custom button and pass back the value to the calling window. So I am just left with these 2 problems. – user3953386 Sep 16 '14 at 19:51
  • You should be able to do .close(returnVal). As for the close button do something like document.getelementsbytag("dialog")[0].close() – benderman Sep 16 '14 at 20:46
  • I tried this document.getElementsByTagName("dialog")[0].close(); but it gives me cannot read property close of undefined. – user3953386 Sep 17 '14 at 03:47
  • Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackoverflow.com/rooms/61406/discussion-on-answer-by-benderman-showmodal-dialog-suddenly-giving-undefined-in). – Taryn Sep 17 '14 at 11:03
0

You can use:

    if(no_support_dialog()){
       showModalDialog(url1,objArgs,"dialogWidth: 450; dialogHeight: 300; resizable: yes");
    }else{
       alert('This browser does not support the native method \'showModalDialog\'');
    }

    function no_support_dialog() {
        return (/\{\s*\[native code\]\s*\}/).test('' + window.showModalDialog);
    }
Code Lღver
  • 15,573
  • 16
  • 56
  • 75
jmacuna
  • 11
  • 2