PHP script for redirection?

Discussion in 'PHP' started by Rakaan, Jun 9, 2007.

  1. #1
    Hi all,

    Where can I find a script which will open a new browser window with a new website when a user visits a certain page n my site?

    I want user to redirect to another website without leaving the existing one. Is it possible?

    Thanks :D
     
    Rakaan, Jun 9, 2007 IP
  2. *louie*

    *louie* Peon

    Messages:
    48
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    did you try onload?
    
    <body onload="window.open('http://www.mydomain.com/file_name.php');return true;">
    
    
    Code (markup):
     
    *louie*, Jun 9, 2007 IP
  3. Rakaan

    Rakaan Well-Known Member

    Messages:
    256
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Thanks Louie got myself sorted from a visual pop up creater.

    <!-- TWO STEPS TO INSTALL POPUP WINDOW:

    1. Paste the first into the HEAD of your HTML document
    2. Use the code to open the popup page on your site -->

    <!-- STEP ONE: Copy this code into the HEAD of your HTML document -->

    <HEAD>

    <SCRIPT LANGUAGE="JavaScript">
    <!-- Idea by: Nic Wolfe (Nic@) -->


    <!-- Begin
    function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=640,height=480,left = 640,top = 360');");
    }
    // End -->
    </script>


    <!-- STEP TWO: Paste this onLoad event handler into the BODY tag -->

    <BODY onLoad="javascript:popUp('http://xxx.domain.com')">

    <!-- Script Size: 0.73 KB -->

    I wonder how can I put it in the background rather than coming in the front?

    Cheers
     
    Rakaan, Jun 9, 2007 IP
  4. *louie*

    *louie* Peon

    Messages:
    48
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    look into focus
    
    <!--body onload='self.focus();'-->
    <BODY onLoad="javascriptopUp('http://xxx.domain.com');self.focus();">
    
    Code (markup):
     
    *louie*, Jun 9, 2007 IP
  5. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #5
    javascript != php
     
    ansi, Jun 9, 2007 IP
  6. jakomo

    jakomo Well-Known Member

    Messages:
    4,262
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    138
    #6
    Hello,

    To redirect an url in PHP is

    header("Location:YOUR URL");

    Best regards
     
    jakomo, Jun 9, 2007 IP
  7. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #7
    not in a new window. not possible with PHP.
     
    ansi, Jun 9, 2007 IP
  8. coderbari

    coderbari Well-Known Member

    Messages:
    3,168
    Likes Received:
    193
    Best Answers:
    0
    Trophy Points:
    135
    #8
    yes in PHP it is not possible to open a new window.you must have to use Javascript.
     
    coderbari, Jun 9, 2007 IP
  9. *louie*

    *louie* Peon

    Messages:
    48
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #9
    if you look at his request it mention the new window and javascript is the way
     
    *louie*, Jun 9, 2007 IP
  10. Rakaan

    Rakaan Well-Known Member

    Messages:
    256
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #10
    Sorry guys if I posted it in the php forums. The existing site is in php so I thought there might be a way to do it in php. Pardon me I am a newbie.

    Back to the topic, as louie mentioned about focus thing? How can I put it in the background please?

    Anyone?

    Thanks
     
    Rakaan, Jun 9, 2007 IP
  11. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #11
    i believe window.focus() is what you want. after you call the popup.
     
    ansi, Jun 9, 2007 IP
  12. Rakaan

    Rakaan Well-Known Member

    Messages:
    256
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #12
    This was the answer.
    Silly me.


    Thanks a lot guys. All sorted. :D
     
    Rakaan, Jun 9, 2007 IP