Page 1 of 1

how_to_open_window_in_php

Posted: Thu Nov 02, 2006 3:04 am
by transistor47
Hello everybody,

I have a HTML page where I make a PDF file. But I´d like it file could open itselft.

The name of the file is inside a PHP variable: $fileName.

Thank you very much

Yours truly,

Daniel Leyva :) :)

Posted: Thu Nov 02, 2006 3:07 am
by itsmani1
use JS

Posted: Thu Nov 02, 2006 9:01 am
by transistor47
Hello,

The problem is I have the name of the file in a variable of PHP: $fileName, besides how could I transmit the content of variable PHP to JavaScript?

Thank you.

Yours truly,

Daniel Leyva

Posted: Thu Nov 02, 2006 9:43 am
by malcolmboston

Code: Select all

$windowURL = 'http://www.google.co.uk'; // URL you want the window to open to
$windowName = 'This Title'; // Name of the opened window
// javascript
window.open('<?php echo $windowURL; ?>','<?php echo $windowName; ?>');

Posted: Thu Nov 02, 2006 9:55 am
by malcolmboston
from a usability / personal preference POV i personally prefer that it is opened in a new window for a variety of reasons

1) Some PDF's take an age to load
2) I would like the site i was looking at to still be there without having to press the back button
3) This is what a user would expect (i personally would)

Posted: Thu Nov 02, 2006 10:01 am
by JayBird
It is my point of view that it should be the user that decides whether a link should be opened in a new window or not

Posted: Thu Nov 02, 2006 10:32 am
by John Cartwright
JayBird wrote:It is my point of view that it should be the user that decides whether a link should be opened in a new window or not
Mine too, browsers give you this option for a reason. I don't like websites predicting my preferences.

Posted: Thu Nov 02, 2006 10:34 am
by Luke
I'm kind of torn on the issue. I think it depends on your demographic... Most users don't even know HOW to open a link in a new window. If this is your target audience, and your customer is linking to an external site, I'd say open in a new window... but not a javascript popup, because those often get blocked anyway.

Posted: Thu Nov 02, 2006 12:30 pm
by Chris Corbyn
The Ninja Space Goat wrote:.... I'd say open in a new window... but not a javascript popup, because those often get blocked anyway.
Only if they are triggered by events the user didn't invoke (such as onload). If the user opens a popup from an onclick event it shouldn't be blocked. The "target" attribute is no longer valid in XHTML strict.

I tend to do:

Code: Select all

<a href="/my/location" onclick="window.open('/my/location/', ..... ); return false;">Click me</a>
This way, with JS on the usual hyperlink is disabled but the onclick runs. With JS off it just behaves like a hyperlink :)

Posted: Mon Nov 06, 2006 1:44 am
by transistor47
Thank you very much.

Yours truly,

Daniel Leyva