Looking for an alternative to window.showModalDialog

The app I am working on used windows.showModalDialog which depreciated, so I replaced it with window,.open which workd fine but with one issue - it is not modal. I have found that one can use window.open Dialog instead but replacing window.open with window.openDialog broke my links.

I had

    ret = window.open(target, "", "scrollbars=no,location=no,statusbar=no,menubar=no,resizable=no,width=500,height=300");

Open in new window


which worked, so I tried:

    ret = window.openDialog(target, "", "scrollbars=no,location=no,statusbar=no,menubar=no,resizable=no,width=500,height=300");

Open in new window


which did not.


I was also looking into using JQuery UI dialog or AJAX dialog, but it seems that those would just display  limited content that you specify and I need to display an actual page. Can anyone help?
LVL 35
YZlatAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontyWeb Ninja at largeCommented:
i like bootbox:

http://bootboxjs.com/

it's easy to set up and configure, and gives you some pre-set options. Of course, it works best with bootstrap...

i've also liked Lightview (http://projects.nickstakenburg.com/lightview), again, easy to use and the documentation was great...

you can use jquery modal to load another page, something like this should work:

// initialize dialog
var dlg = $("#dialog").dialog({ autoOpen: false,
  height: 600,
  width: 350
});

// load content and open dialog
dlg.load('url/to/otherPage').dialog('open');

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
YZlatAuthor Commented:
@Big Monty, what type of control is #dialog? is it a div?
Big MontyWeb Ninja at largeCommented:
it can be, its the markup for your dialog box. in this case, it can be just an empty div on your page
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

YZlatAuthor Commented:
I have tried your example but all that appeared on the page on click of a link is a close button. No content was shown  

<html>
<head>
 <script src="Script\jquery-2.2.0.js"></script>
  <script src="Script\jquery-ui-1.8.24.js"></script>
 <script>
 $( document ).ready(function() {
$("#hlk1").click(function(){ 
	// initialize dialog
var dlg = $("#dialog").dialog({ autoOpen: false,
  height: 600,
  width: 350
});

// load content and open dialog
dlg.load('www.google.com').dialog('open');
});
});

 </script>

</head>
<body>
<a href="#" id="hlk1" >Click here</a>
<div id="dialog">
  
</div>
</body>
</html>

Open in new window

Big MontyWeb Ninja at largeCommented:
your fiddle there is no reference to jquery, can you fix and then resend?
YZlatAuthor Commented:
I got it to work. I replaced www.google.com by test.html. there is only one thing - in Chrome I got an error message

XMLHttpRequest cannot load file:///C:/Users/MyUser/Desktop/test.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

Open in new window


How could these be cross origin requests if both files are in the same folder on the same machine?
Big MontyWeb Ninja at largeCommented:
whats the code?
YZlatAuthor Commented:
<html>
<head>
 <script src="Scripts\jquery-2.2.0.js"></script>
  <script src="Scripts\jquery-ui-1.8.24.js"></script>
 <script>
 $( document ).ready(function() {
$("#hlk1").click(function(){ 
	// initialize dialog
var dlg = $("#dialog").dialog({ autoOpen: false,
  height: 600,
  width: 350
});

// load content and open dialog
dlg.load('test.html').dialog('open');
});
});

 
 
 </script>

</head>
<body>
<a href="#" id="hlk1" >Click here</a>
<div id="dialog">
  
</div>
</body>
</html>

Open in new window

Big MontyWeb Ninja at largeCommented:
I'm not sure why thats happening, if the file is located in your root folder. I would open another question up and see if other experts have any ideas...
YZlatAuthor Commented:
Just a side note for anyone who has the same issue. "Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource." as suggested by error, I needed to use one of the listed prorocols to be able to send cross-origin requests. So I created a project on localhost and cross-origin request worked fine.


Thanks Big Monty! You have been a great help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.