Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.
NDD Camp 2024

Quick PHP Question

Status
Not open for further replies.

Bob

Jedi Master
Joined
Apr 8, 2002
Messages
3,102
Reaction score
29
Feedback: 116 / 1 / 0
I cannot seem to figure out how to do this or find it anywhere.

I need to open a link in a NEW browser window.

In HTML, you do it with:

a href=". . . " target="_BLANK"


In JavaScript, you do it with:

window.open(". . . ");

How do you do this in PHP?

I tried:
header('Window-target: NEW');
header('Location: http://. . . ');

But I got a "Headers already sent" error in the main document.

ACK! Help please!

-Bob
 

GiantDomains

President
Legacy Exclusive Member
Joined
Sep 15, 2002
Messages
6,569
Reaction score
1
Feedback: 10 / 0 / 0
Why don't you just use javascript within the php document? That's the way I do it. Not sure if there is an actual php command, but I guess there must be.
 

Darren06

Level 8
Legacy Platinum Member
Joined
Sep 22, 2003
Messages
1,853
Reaction score
2
Feedback: 14 / 0 / 0
Ah you cant do this in php... its an active element which means it can only be used in browser code.
 

WebCat

Level 7
Legacy Exclusive Member
Joined
Mar 9, 2003
Messages
913
Reaction score
0
Feedback: 0 / 0 / 0
Bob said:
I cannot seem to figure out how to do this or find it anywhere.

I need to open a link in a NEW browser window.
I tried:
header('Window-target: NEW');
header('Location: http://. . . ');

But I got a "Headers already sent" error in the main document.

ACK! Help please!

-Bob
Hey Bob, I'm no php guru, but I think the server is telling you you're resending http headers again, which it sounds like the server doesn't like.

I would pursue generating an html doc, with a meta equiv tag and research if there's an http header that will open a new window, similar to how the "refresh" will redirect. I definitely don't know what every one of the http headers are and do. I think there's about 60 or so, not including mime type headers.

Another possibility I'd experiment with would be to use php to generate a javascript doc that in turn executes and opens the new window.

I don't know if that helps or not. I'm probably more confused than you! :)

WebCat
 

.com.net.org

Level 8
Legacy Platinum Member
Joined
Oct 20, 2002
Messages
1,951
Reaction score
0
Feedback: 0 / 0 / 0
Try this Bob.

Code:
<?php
echo '<a href="http://www.dnforum.com" target="_blank">www.dnforum.com</a>';
?>
 

ctrlnet

New Member
Legacy Gold Member
Joined
Feb 14, 2004
Messages
4
Reaction score
0
Feedback: 0 / 0 / 0
Drop me a pm if you ever have any PHP-questions or if the above didn't help you out. Am fairly experienced and don't mind helping out! (That goes for all of you)
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Sedo - it.com Premiums

IT.com

Premium Members

AucDom
UKBackorder
Be a Squirrel
MariaBuy

Our Mods' Businesses

URL Shortener
UrlPick.com

*the exceptional businesses of our esteemed moderators

Top Bottom