Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    May 2012
    Posts
    142
    Thanks
    112
    Thanked 0 Times in 0 Posts

    Trying to apply "target=_blank" when linking.

    RESOLVED:I would like the user to click on my image, and go to the page ($mylink), BUT ... in a new window .
    My code does work, BUT I cannot figure out how (or where) to implement the target="_blank" in my code.

    my code:
    PHP Code:
    echo "<a href='$mylink>";
    echo 
    "<img src='images/".$mypic."' width='250' >";  
    echo 
    "</a>"
    I would appreciate any help. Thank you in advance.
    Last edited by Eggweezer; 07-17-2013 at 02:57 AM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    echo "<a href='$mylink' target='_blank'>";

    ... and note you're missing a single quote after the k in mylink.

  • Users who have thanked mlseim for this post:

    Eggweezer (07-17-2013)

  • #3
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,911
    Thanks
    15
    Thanked 227 Times in 227 Posts
    You can also use the javascript window.open(); method, which opens in a new window by default. You can see how it's used in the 'Abouts' links on my home page, just check the source code.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  • Users who have thanked DrDOS for this post:

    Eggweezer (07-17-2013)

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Flame war in...3....2.....1....
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • Users who have thanked whizard for this post:

    Eggweezer (07-17-2013)

  • #5
    Regular Coder
    Join Date
    May 2012
    Posts
    142
    Thanks
    112
    Thanked 0 Times in 0 Posts
    Perfect. Thank you all, and thank you for your tips.
    I will mark this thread "Resolved".

  • #6
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,603
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Of course all that target does is to remove one of the options on where the page can be opened for those visitors who don't have their browser set to ignore it.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    Eggweezer (07-17-2013)

  • #7
    Regular Coder
    Join Date
    May 2012
    Posts
    142
    Thanks
    112
    Thanked 0 Times in 0 Posts
    Ooh, I didn't really know that.
    What would be your recommendation?

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Is target even a valid attribute on an anchor? I thought it was never validated since it removes control from the browser / is an accessibility issue?
    In any case, this has *nothing* to do with PHP. Moving to HTML/CSS forum.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    Eggweezer (07-18-2013)

  • #9
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,622
    Thanks
    6
    Thanked 1,001 Times in 974 Posts
    Quote Originally Posted by Fou-Lu View Post
    Is target even a valid attribute on an anchor? I thought it was never validated since it removes control from the browser / is an accessibility issue?
    It used to be as of HTML 2, was deprecated in HTML 4 (strict mode) and has been reintroduced in HTML 5 because of all these lazy people that don’t adhere to any specification or recommendation and continue to use deprecated code. So technically, in HTML 5 it is a valid attribute.

    I’m really surprised that the PHP folks actually have the guts to remove deprecated features. They could also argue that “everybody is using magic_quotes so we better keep it to not break any outdated applications”.

  • Users who have thanked VIPStephan for this post:

    Eggweezer (07-18-2013)

  • #10
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Not only that, they're hardcore fast at it (sometimes :P).
    Magic_quotes_gpc -> Deprecated 5.3.0 -> removed 5.4.0 O.o
    That was super fast. Comparing to:
    Register_globals -> disabled default 4.2.0 -> deprecated 5.3.0 -> removed 5.4.0 O.o

    Huge gap there. Unofficially deprecated by 4.2.0 (every PHP dev would be like "don't rely on them!").
    Honestly, I expected these to deprecate and hang out until 6.0. I *hope* the mysql library sticks around until 6.0 at least (unlike magic quotes which is easy to fix [and people should have self-fixed them years ago anyway ], the mysql has a huge reliance by people). If I read notes of like 5.6 release -> remove mysql library support, I'd really be like O.o o.O

    Funny about the anchor though. I guess laziness pays off?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    Eggweezer (07-18-2013)

  • #11
    Regular Coder
    Join Date
    May 2012
    Posts
    142
    Thanks
    112
    Thanked 0 Times in 0 Posts
    Wow. Thank you all.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •