SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ShowModalDialog() issue

    Hi All,

    I am using the ShowModalDialog() to display a new window. However i want to pass the HTMl string to the new window rather than display a predefined html page. How do I do this. I have been able to achieve some results, however the HTML is not displayed correctly. Is their any limitation on the length of the HTML string that can be passed to the new window.

    Wouldnt mind if someone explains this with an example.

    Thanks for reading this post.

    Regards,
    Lols.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,784
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    I assume this is for an intranet where all of the computers are running Internet Explorer as no other browser understands that command.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ShowModalDialog()

    Quote Originally Posted by felgall
    I assume this is for an intranet where all of the computers are running Internet Explorer as no other browser understands that command.
    Well Ok. You can give me a solution for an IE. However this will also be accessible using an internet. Do you know of any cross browser command that can enable you to show new windows as modal boxes.

    Thanks for the response.

    REgards,
    lols

  4. #4
    SitePoint Zealot Mr. Ram's Avatar
    Join Date
    Nov 2005
    Posts
    139
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    cross-browser compatible code for showModalDialog

    Internet Explorer
    retval = window.showModalDialog("attach.html",txtData);

    Compatible with Internet Explorer and Firefox
    if(window.showModalDialog) // IE
    { retval = window.showModalDialog("attach.html",txtData);
    }
    else // Firefox
    { retval = window.open("attach.html", txtData, "left=100,top=100,width=550,height=300,dependent,modal");
    window.onfocus=function()
    {
    if(retval && !retval.closed)
    retval.focus();
    }
    return false;
    }

    The problem with this code is that window.open is asynchronous -- it does not block the JavaScript execution until the window has finished loading. Therefore, you may execute the line after the window.open line before the new window has finished. You can deal with this by having an onload handler in the new window and then call back into the opener window (using window.opener).

  5. #5
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mr Ram,

    How about deleting your post to the wrong thread?

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,784
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    That entry for firefox only forces the window to stay in front of the opener, it doesn't make it modal. The parameter is ignored in other browsers. There is no way to make a popup modal in any browser other than IE.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  7. #7
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ShowModalDialog()

    Thanks for all your replies.

    One doubt has still not been solved.

    I have been able to achieve some results, however the HTML is not displayed correctly. Is their any limitation on the length of the HTML string that can be passed to the new window.
    Also once the data has been dynamically passed to the new modal dialog, how do i display it in that page.

    Thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •