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 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2009
    Posts
    62
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Open URL in another tab/window

    Hey all,

    Just wondering if there is a way of opening a location in a new tab/window on the users browser, without the user having to click any thing?

    Basically, my code allows the user to select an XML file which is then manipulated and saved to the server (need this as a record of what has been edited), and as the final step I'd like the file displayed to the user, but in another tab.

    Thanks.

  • #2
    Regular Coder olidenia's Avatar
    Join Date
    Oct 2009
    Location
    Sitting In Front Of A Screen
    Posts
    110
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Is this what you are looking for?
    It can be done with javascript, modifying the automatic redirect script:

    You can edit the Timeout to 0 if you want it to redirect instantly.

    Code:
    <script type="text/javascript"><!--
    setTimeout('Redirect()',4000);
    function Redirect()
    {
      window.open = '<?php echo "url_of_document.xml"; ?>';
    }
    // --></script>
    I have edited it to "window.open" so it opens a new window.
    Last edited by olidenia; 11-17-2010 at 01:34 PM.
    It's easy once you know how...

  • #3
    New Coder
    Join Date
    Jun 2009
    Posts
    62
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Thanks for the quick reply. It's pretty much what I am trying to do, only I'd like the file opened in a new tab/window so that the original page is still there.

    Also, just tried the code you supplied and it's giving me 'Error on page'.

    Thanks.

  • #4
    Regular Coder olidenia's Avatar
    Join Date
    Oct 2009
    Location
    Sitting In Front Of A Screen
    Posts
    110
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Ok, sorry.

    This will work, you can adjust other elements also.

    Code:
    <script type="text/javascript"><!--
    setTimeout('Redirect()',0);
    function Redirect()
    {
      window.open('location_document.xml','mywin','left=20,top=20,width=500,height=500,toolbar=1,resizable=0');
    }
    // --></script>
    It's easy once you know how...

  • #5
    New Coder
    Join Date
    Jun 2009
    Posts
    62
    Thanks
    9
    Thanked 0 Times in 0 Posts
    The code is pretty self explanitory, thanks for that.

    Plugged it in and still getting 'Error on page' though. If I change the timeout the 'Error on page' message does not kick in until after the the function fires. the file location is correct, as tried printing to screen and it works fine.

    Thanks.

  • #6
    Regular Coder olidenia's Avatar
    Join Date
    Oct 2009
    Location
    Sitting In Front Of A Screen
    Posts
    110
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Thats strange, it works fine on my browser, I have replaced the url with http://google.com and it works fine.

    Here is the exact script:

    Code:
    <script type="text/javascript"><!--
    setTimeout('Redirect()',1000);
    function Redirect()
    {
      window.open('http://google.com' , 'mywin' , 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); 
    
    }
    // --></script>
    It's easy once you know how...

  • #7
    New Coder
    Join Date
    Jun 2009
    Posts
    62
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Hmm, it works with Google, but will not work with my XML file - even if I make a clickable link to the file location it doesn't want to know, which is odd as the location is correct. Guess I'll have to put this on the back burner for the time being!

    Thanks for the help.


  •  

    Posting Permissions

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