Results 1 to 4 of 4

Thread: JS, showModalDialog problem.

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    JS, showModalDialog problem.

    I have the following JS:
    Code:
    function openSelectVisitor(iBookingKey)
    {
    	var sFeatures = ''
    				
    	sFeatures=''
    	sFeatures+='top=100,'
    	sFeatures+='left=200,'
    	sFeatures+='height=500px,'
    	sFeatures+='width=400px,'
    	sFeatures+='scrollbars=no,status=no,toolbar=no'
    	window.showModalDialog('SelectVisitor.aspx?BookingKey='+iBookingKey,'SelectVisitor',sFeatures)
    }
    This works fine, and my popup window is shown.

    In this popup I have a close button, and in page load I do:
    VB Code:
    1. btnClose.Attributes.Add("onClick", "javascript:window.close();")
    Now when I click this close button the page does indeed close...but for some strange reason, another instance of this is opened, which is NOT a Modal Dialog, but instead a modeless popup...plus this time the address bar is visible.
    I have put a break point on the Page_Load event of the popup, and sure enough, when I click the close button, the Page_Load event gets fired again.

    I have absolutely no other code in the popup except the btnClose.Attributes bit.

    If I change my main calling JS function so it shows the Popup and modeless:
    Code:
    window.Open('SelectVisitor.aspx?BookingKey='+iBookingKey,'SelectVisitor',sFeatures)
    Then I do not have this problem and the popup closes fine when close.

    Any ideas?

    Woka

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: JS, showModalDialog problem.

    I think you need to change this:
    Code:
    btnClose.Attributes.Add("onClick", "javascript:window.close();")
    To this:
    Code:
    btnClose.Attributes.Add("onClick", "window.close();")
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: JS, showModalDialog problem.

    Got it:
    The button was causing the popup to submit, to stop this I added Return False to the JS:
    VB Code:
    1. btnClose.Attributes.Add("onClick", "javascript:window.close();return false;")

    Woka

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: JS, showModalDialog problem.

    Yuo forgot to mention that it was a submit button.

    If it never submits then it is best to use a <button>Button Text</button> tage.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width