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,074
    Thanks
    0
    Thanked 256 Times in 252 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>
    Last edited by glenngv; 02-22-2007 at 09:36 PM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #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,074
    Thanks
    0
    Thanked 256 Times in 252 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.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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