Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Location
    Loughborough (UK)
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ModalWindow Redirect

    Hi all,

    I have in my web application, a modal window popup (I know people don't like these, but it is only for an intranet). When they click a value, I want to redirect (using javascript) to another page carrying the value with me. I have used the following code, but when you click the link, it opens a new window, despite the fact I have set the base target as 'self'. Any ideas?

    <script type="text/javascript">
    function Select(strValue)
    {
    window.location = "/Page.aspx?Value="+ strValue;
    }
    </script>
    <base target="_self">

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Modal dialogs inherent behavior is that a new window is opened for redirecting links and form submission. I don't know the reason behind that.

    Try this workaround:
    Code:
    <head>
    <script type="text/javascript">
    
    window.name = "modalWin";
    
    function Select(strValue)
    {
        window.open("/Page.aspx?Value="+ strValue, window.name);
    }
    </script>
    </head>
    If you are also submitting the form, you can set the form target to whatever you put in the window.name so that it won't open a new window.
    Code:
    <form ... target="modalWin">
    ...
    <input type="submit" value="Submit" />
    </form>

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Location
    Loughborough (UK)
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thank You!

    Finally got around to trying this... worked a treat!

    Thanks very much!

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Glad to be of help.
    Discovered that trick in my past project where my colleagues used to create framesets in the modal dialog to avoid new window from opening.


  •  

    Posting Permissions

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