How does one launch a new page in Php that is to open in a new Web browser and not in the current page.
So for example say I want to open page xyz.php
via regular HTML I would open this in a new browser with target=“new”
but in Php I would open (process) this page via:
header("Location: xyz.php ");
exit();
So how does one then get xyz.php to open in a new browser window and not the current one? Now it seems that there is actually no way to do this in Php alone, but that one needs to use JavaScript along with Php to get this job done? So my question is then how does that JavaScript & Php code look that would result in xyz.php to open in a new browser window and not the current one?
You use the JavaScript window.open() command to suggest that the new page should open in a new window. Of course the browser owner can have it set up so that the command opens in a new tab instead or even in the same window it they want that command to work that way.
You wouldn’t use any PHP at all since any PHP runs before the web page loads and can only load into the current window. The only way to ask your visitor to allow the page to be opened in a new window is to write the code to load the page in JavaScript within the previous page using a JavaScript window.open command.
A window.open can take up to four parameters.
The first parameter identifies the name of the page to load.
The second contains the name of the window or frame to open that page in (use ‘_blank’ to request a brand new window every time).
The third parameter contains suggestions as to what size and position the new window should be in and whether to include menus, toolbars etc.
The fourth parameter is almost never used and specifies whether when you are reusing an existing window whether the new page should or should not replace the prior page in the history.
So to do what you want you could specify the following in JavaScript to open the page in a new window if your visitor hasn’t overridden it:
in the page where you click something after which you want xyz.php to open in a new window, use window.open() in the onclick event handler function to open xyz.php in a new window.
Sorry, but you have completely misunderstood what I want to get done.
I have a rather large Php program, which program access a MySQL database and does a whole bunch of this as it loops through a While Loop pulling each row from the MySQL database. Now when a certain conditions are met, from within this While Loop, I need to call another Php program, I need this other Php program to run in new Web browsers. So is there any way to get this done? So this is not the simple issue of a clicking on a HTML link and wanting the resulting Web page to open in a new web browser, of course that is easy and can be done via window.open(). But what I am talking about here is something entirely different, again from within a LARGE Php program there is a need to call at times another Php program, and since we do not want to interrupt the running of the current Php program, we need the new one to open in a new Web browser.
The only way to suggest opening in a new window is to use JavaScript - it cannot be done with PHP. PHP can only create a web page, it cannot say where that page is to be displayed.
Ay, that is a real shame
A real short coming of Php. I cannot believe it is 2010 and this limitation of Php has not been addressed by now!!! OTN, you can do this in JSP and Java, specifically JSP that is a competition to Php has allowed for this for years, so I am amazed that Php community has not asked for this capability by now.