Re: opening a new window from php script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2011-03-28 at 17:44 +0200, Grega LeskovÅek wrote:

> I would still like to offer in my CMS to be able to choose in which
> browser I want to display the current page.  Is this possible or I in
> program can open only default browser? Can I at least choose wheter to
> open a new tab or a new window?
> Thanks in advance,
> -- When the sun rises I receive and when it sets I forgive ->
> http://moj.skavt.net/gleskovs/
> Always in Heart, Grega LeskovÅek
> 
> 
> 
> 
> 2011/3/27 Richard Quadling <rquadling@xxxxxxxxx>:
> > On 26 March 2011 10:22, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx> wrote:
> >> On Fri, 2011-03-25 at 18:05 -0700, Tommy Pham wrote:
> >>
> >>> On Fri, Mar 25, 2011 at 2:59 PM, Grega LeskovÅek <legrega@xxxxxxxxx> wrote:
> >>> > I am working on CMS designed to those who are unfamiliar  with a
> >>> > computer world and I want to offer a task where on a push of a button
> >>> > it will save current working page in textarea/s and open this page in
> >>> > a new tab or in a new window.
> >>>
> >>> PHP is server side.  "push of a button" is client side.  Google
> >>> javascript+onClick.
> >>>
> >>> > I googled some, but am still not sure how can I do it.
> >>> >
> >>> > Do I have to use target="_new" - I can not do this - I am working this
> >>> > for my University seminar and it has to be valid HTML5.
> >>> >
> >>> > Please help me improve my plan
> >>> > 1. I check wheter the user is using windows, linux, mac and then show
> >>> > appropriate possibility of all browsers for the targeted platform
> >>> > (WIN:IE,SA,FF,CH,OP, LINUX:FF.CHROMIUM and I need help for the mac
> >>> > also besides SA and FF what does it have among browsers?)
> >>>
> >>> Have you tried to google for browser versions and platform?  While
> >>> searching for the same thing long time ago, I found a site that lists
> >>> them.  Also, note that since you'll be using onClick for "push of a
> >>> button", beware of Javascript version difference among the browsers.
> >>> IIRC, IE is supports 1.3 and FF supports 1.9.  Haven't tested the
> >>> others so couldn't tell you.
> >>>
> >>> > 2. When the browser clicks button with the image of browsers inside
> >>> > anchor I target _new and location of the current file
> >>> >
> >>> > ?1 How can I offer option to open a new window not a new tab?
> >>> > ?2 How can I avoid the target attribute?
> >>> > ?3 How can I make a click on an image to produce action - or what do
> >>> > You suggest me to use - I would prefer img element not  button with an
> >>> > image - how can I do this?
> >>> >
> >>> > Once I will finish it I will offer here software to everybody so I
> >>> > will be able to get some response and improve it and this is one of
> >>> > the major problems otherwise it is already functional.
> >>> >
> >>> > Please help me, thanks in advance - or ? You think I could do this better in JS?
> >>> > -- When the sun rises I receive and when it sets I forgive ->
> >>> > http://moj.skavt.net/gleskovs/
> >>> > Always in Heart, Grega LeskovÅek
> >>> >
> >>>
> >>> I don't know if you have Flash in your tool belt but have you
> >>> considering using it?  It may simply your life with various browsers
> >>> and their versions across different platforms.  Note: Flash does tend
> >>> to be sluggish in terms of loading time and how much of what you need
> >>> the Flash to do.
> >>>
> >>> Regards,
> >>> Tommy
> >>>
> >>
> >>
> >> I'd avoid trying to guess the browser entirely. There are always loads
> >> of fringe browsers that are in use, and things like Wine that allows
> >> people to run IE on Linux, as well as other Windows-based browsers too.
> >> As soon as you're trying to write a script that detects a specific
> >> browser and does something then you're already doing it wrong. Don't
> >> test for the browser, test for the feature that you're using. Javascript
> >> has a useful function called hasFeature which may help here.
> >>
> >> The main reason why it's bad to try and detect a browser and act on it
> >> is because you can get many browsers that work across a wide variety of
> >> operating systems such as Fx & Opera, which vary from version to version
> >> and OS to OS.
> >>
> >> Thanks,
> >> Ash
> >> http://www.ashleysheridan.co.uk
> >>
> >>
> >>
> >
> > A common approach to web dev is to start with a dumb page - just HTML
> > and then add CSS and JS. This is known as progressive enhancement.
> >
> > Another approach which I've read about recently is called regressive
> > enhancement. Essentially, you start at the cutting edge, using the
> > functionality that you want (canvas for example), and then add in the
> > missing features.
> >
> > As more of the browsers that support the newer features become the
> > popular ones, you end up with less code providing support for older
> > browsers. So, when every browser supports canvas, you don't need to
> > install any code to emulate the canvas. Modenizr and YepNope are the
> > tools I read about for this.
> >
> > --
> > Richard Quadling
> > Twitter : EE : Zend
> > @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
> >


Firstly, this isn't something that can be done in PHP, as PHP is a
server-side language, so things like opening new tabs/windows isn't
possible.

You can open new windows with Javascript, but you can't determine what
browser they open in, or if indeed that a given browser is even
installed on that computer.

On to your last question. I believe some browsers do have an api to open
a link in a new tab or window specifically, but they differ from browser
to browser. One way of ensuring a link opens in a new window and not a
tab is to open the window with Javascript and resize it, which should
force that browser to not open it in a tab.

However, if you're trying to offer this from your CMS, then maybe you
should really think about limiting the control your users have if you
really think they are going to break the layout in some browsers.

Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux