CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: target="_blank"

  1. #1
    Join Date
    May 2002
    Posts
    1,435

    target="_blank"

    Here's a link to a Google Earth map:

    HTML Code:
    <!-- The full link (code supplied by Google)-->
    <a href="http://maps.google.com/maps?f=q&amp;hl=en&amp;geocode=&amp;q=merwin+ave,+cleveland+ohio&amp;sll=37.0625,-95.677068&amp;sspn=49.71116,59.414063&amp;ie=UTF8&amp;layer=c&amp;cbll=41.488171,-81.685696&amp;panoid=7Q2mWLjC1OLCkHJCCpdbeQ&amp;cbp=1,256.01868693765914,,0,8.188362819652383&amp;ll=41.504271,-81.706095&amp;spn=0.005786,0.007253&amp;z=14&amp;source=embed" style="color:#0000FF;text-align:left" target="_blank">View Larger Map</a>
    
    <!-- Some things <.CUT.> for readability -->
    <a href="http://maps.google.com/maps?<.CUT.>;source=embed" style="<.CUT>" target="_blank">View Larger Map</a>
    The target="_blank" did not exist in the original code supplied by Google. I added it because I want this link to open in a new window - but it doesn't - it opens in the same window. Why? How can I fix it?

  2. #2
    Join Date
    Jul 2005
    Location
    Currently in Mexico City
    Posts
    568

    Re: target="_blank"

    strange... I've tested the code with target="_blank" and it always opens in a new window in almost any browser. Without it, the link opens as configured in web browser by default (if none is set - it's the same window)

    Just tested in: Firefox 3.0.1, Opera 9.52, Google Chrome 0.2.149.29, Internet Explorer 7.0.6001.18000, Safari 3.1.2, Flock 1.2
    Last edited by Xeel; September 19th, 2008 at 12:45 PM.
    Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?

    I had a nightmare last night. I was dreaming that I’m 64-bit and my blanket is 32-bit and I couldn’t cover myself with it, so I’ve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)

    //always looking for job opportunities in AU/NZ/US/CA/Europe :P
    willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));

    USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!

  3. #3
    Join Date
    May 2002
    Posts
    1,435

    Re: target="_blank"

    Quote Originally Posted by Xeel
    strange... I've tested the code with target="_blank" and it always opens in a new window in almost any browser. Without it, the link opens as configured in web browser by default (if none is set - it's the same window)

    Just tested in: Firefox 3.0.1, Opera 9.52, Google Chrome 0.2.149.29, Internet Explorer 7.0.6001.18000, Safari 3.1.2, Flock 1.2
    Are you saying you tested the actual code I provided and it did work correctly? It doesn't work for me in either Firefox 3.0.1 or IE 6.0.2900.2180.

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: target="_blank"

    Works for me.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5

    Re: target="_blank"

    Your link works exactly as expected for me on Firefox 3 and Safari 3 on a Mac.

  6. #6
    Join Date
    Jul 2005
    Location
    Currently in Mexico City
    Posts
    568

    Re: target="_blank"

    just to be sure, use this =):
    HTML Code:
    //add this to your default attached js
    function targetBlank(url){
       window.open(url, '_blank', 'menubar=yes, toolbar=yes, location=yes, directories=yes, fullscreen=no, titlebar=yes, hotkeys=yes, status=yes, scrollbars=yes, resizable=yes');
    }
    
    //then you just use this method instead of target="_blank"
    
    <a href="#" style="..." onclick="targetBlank('http://maps.google.com/maps...')">View Larger Map</a>
    Don't tell me this does not work either.

    Btw, I was going to write an article on some related subject. It's supposed that XHTML standard doesn't have target attribute for <a>. From the moment I saw this I've been wondering how we should avoid it if we want both: be able to open a new browser window, and our websites to correspond WCAG-AAA, where it's said our web pages should work without js. Actually what I understood was that WCAG-AAA is a perfect standard for text web browsers...

    This is not flud, I'm just thinking aloud...
    Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?

    I had a nightmare last night. I was dreaming that I’m 64-bit and my blanket is 32-bit and I couldn’t cover myself with it, so I’ve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)

    //always looking for job opportunities in AU/NZ/US/CA/Europe :P
    willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));

    USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured