how_to_open_window_in_php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
transistor47
Forum Newbie
Posts: 3
Joined: Thu Nov 02, 2006 2:57 am

how_to_open_window_in_php

Post 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 :) :)
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

use JS
transistor47
Forum Newbie
Posts: 3
Joined: Thu Nov 02, 2006 2:57 am

Post 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
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post 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; ?>');
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post 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)
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 :)
transistor47
Forum Newbie
Posts: 3
Joined: Thu Nov 02, 2006 2:57 am

Post by transistor47 »

Thank you very much.

Yours truly,

Daniel Leyva
Post Reply