View Full Version : PHP script for redirection?
Rakaan
Jun 9th 2007, 11:36 am
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
*louie*
Jun 9th 2007, 12:06 pm
did you try onload?
<body onload="window.open('http://www.mydomain.com/file_name.php');return true;">
Rakaan
Jun 9th 2007, 12:16 pm
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
*louie*
Jun 9th 2007, 12:22 pm
look into focus
<!--body onload='self.focus();'-->
<BODY onLoad="javascriptopUp('http://xxx.domain.com');self.focus();">
ansi
Jun 9th 2007, 1:23 pm
javascript != php
jakomo
Jun 9th 2007, 1:27 pm
Hello,
To redirect an url in PHP is
header("Location:YOUR URL");
Best regards
ansi
Jun 9th 2007, 1:29 pm
not in a new window. not possible with PHP.
coderbari
Jun 9th 2007, 1:42 pm
yes in PHP it is not possible to open a new window.you must have to use Javascript.
*louie*
Jun 9th 2007, 1:59 pm
if you look at his request it mention the new window and javascript is the way
...which will open a new browser window .......
Rakaan
Jun 9th 2007, 2:28 pm
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
ansi
Jun 9th 2007, 2:49 pm
i believe window.focus() is what you want. after you call the popup.
Rakaan
Jun 9th 2007, 2:58 pm
look into focus
<!--body onload='self.focus();'-->
<BODY onLoad="javascriptopUp('http://xxx.domain.com');self.focus();">
This was the answer.
Silly me.
Thanks a lot guys. All sorted. :D
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.