+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: WP code for opening url links in new window

  1. #1
    ata.online is offline x10 Sophmore ata.online is an unknown quantity at this point
    Join Date
    Oct 2009
    Location
    England
    Posts
    159

    Question WP code for opening url links in new window

    Does anyone know the html code for opening an article url in a new window and not actually exit my site?

    How to configure it in wp dashboard?

    Thanks.

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: WP code for opening url links in new window

    The HTML code is:

    HTML Code:
    <a title="news" href="http://cnn.com" target="_blank">The latest News</a>

    If you are talking about the "Links" part of WP, scroll down a bit when you are creating/editing the link to the section named "Target" there are three radio buttons. Click on "_blank"

    If you are talking about a link that you put when you are writing a blog entry, there is an option for that if you use the WYSIWYG editor.

    If you are talking about links that might be put in via comments, I do not know.
    Last edited by descalzo; 05-17-2010 at 04:39 PM.

  3. #3
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: WP code for opening url links in new window

    I can't find any way of doing it in a stock Wordpress install without editing every single post. I did however find this plugin that looks like what you want.

  4. #4
    essellar's Avatar
    essellar is offline Community Advocate essellar has a spectacular aura about
    Join Date
    Feb 2010
    Location
    Toronto, Ontario, CA
    Posts
    1,153

    Re: WP code for opening url links in new window

    You can set the default target for all links to be _blank or _new using the <base> tag in the page head:

    Code:
    <base target="_blank" />
    Note, though, that deciding for your users is considered bad form these days.
    “Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
    "It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)

  5. #5
    ata.online is offline x10 Sophmore ata.online is an unknown quantity at this point
    Join Date
    Oct 2009
    Location
    England
    Posts
    159

    Re: WP code for opening url links in new window

    Quote Originally Posted by descalzo View Post
    The HTML code is:

    HTML Code:
    <a onclick="pageTracker._trackPageview ('/outgoing/http_cnn_com');" title="news" href="http://cnn.com" target="_blank">The latest News</a>

    If you are talking about the "Links" part of WP, scroll down a bit when you are creating/editing the link to the section named "Target" there are three radio buttons. Click on "_blank"

    If you are talking about a link that you put when you are writing a blog entry, there is an option for that if you use the WYSIWYG editor.

    If you are talking about links that might be put in via comments, I do not know.
    Hi,
    Do you mean i have to embed the code to all the articles for it to work?

    Thanks.

  6. #6
    ata.online is offline x10 Sophmore ata.online is an unknown quantity at this point
    Join Date
    Oct 2009
    Location
    England
    Posts
    159

    Re: WP code for opening url links in new window

    Quote Originally Posted by lemon-tree View Post
    I can't find any way of doing it in a stock Wordpress install without editing every single post. I did however find this plugin that looks like what you want.
    Hi,
    I just activated the plugin. Anything i need to be doing as it doesn't seem to work.

  7. #7
    ata.online is offline x10 Sophmore ata.online is an unknown quantity at this point
    Join Date
    Oct 2009
    Location
    England
    Posts
    159

    Re: WP code for opening url links in new window

    Quote Originally Posted by essellar View Post
    You can set the default target for all links to be _blank or _new using the <base> tag in the page head:

    Code:
    <base target="_blank" />
    Note, though, that deciding for your users is considered bad form these days.
    Hi, thanks for that. However, you mentioned the base tag in page template. I have the following code:


    <?php get_header(); ?>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post">
    <h2><?php the_title(); ?></h2>
    <div class="entry">
    <?php the_content(); ?>
    </div>
    </div>
    <?php endwhile; endif; ?>
    <?php edit_post_link('Edit.', '<p>', '</p>'); ?>

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>


    Where can i embed <base target="_blank" /> into the above template?

    You mentioned:
    Note, though, that deciding for your users is considered bad form these days.

    I understand what you are saying, but visitors will still be able to access their website without leaving mine. Besides, it is their content on my site.

    Thanks.
    Last edited by ata.online; 05-18-2010 at 05:11 AM.

  8. #8
    thanks_but_no_thanks is offline x10Hosting Member thanks_but_no_thanks is an unknown quantity at this point
    Join Date
    May 2010
    Posts
    12

    Re: WP code for opening url links in new window

    Not sure what your trying to do here?

    If you change the base tag ALL links will open in a new window, including viewing pages and posts.

    If you wish to do this place the tag in the header sectin of your website, typically in wordpress look for a file named header.php in your template folder.

    within the <head> and </head>

    add
    <base target="_blank" />

    all your hyperlinks will now open in a new window, would`nt advise this though

  9. #9
    ata.online is offline x10 Sophmore ata.online is an unknown quantity at this point
    Join Date
    Oct 2009
    Location
    England
    Posts
    159

    Re: WP code for opening url links in new window

    Hi, thanks for that.
    I embedded code as shown. You mentioned that you would not recommend it and i came across an article on this subject:

    http://articles.sitepoint.com/articl...nks-new-window
    Does anyone know how i can set a 'warning' message to users as mentioned in this article?


    Also, from my personal experience, i find it very irritating when i visit a site and click a link hoping that it would open in a new window but doesn't. Hence, when i leave the previous site, i alway have to copy and paste the url in a new window and then press the back button.

    It would be much easier for me to have links set to open in a window. I wish to remain on the current site due to other interesting features/resources/articles shown.
    Last edited by ata.online; 05-20-2010 at 05:54 PM.

  10. #10
    ata.online is offline x10 Sophmore ata.online is an unknown quantity at this point
    Join Date
    Oct 2009
    Location
    England
    Posts
    159

    Re: WP code for opening url links in new window

    I noticed that every link opens in a new window including the anchor HOME link which is slightly strange.

    Is it possible to only have article links to open in new window and not my own website links?

    Or would that involve adding html code to each article, which would be rather tedious?
    Last edited by ata.online; 05-20-2010 at 06:08 PM.

+ Reply to Thread
Page 1 of 3 123 LastLast

Similar Threads

  1. Security warning when using ad code in dialog window
    By patchnpuki in forum Free Hosting
    Replies: 1
    Last Post: 07-10-2008, 05:18 PM
  2. Window or others?
    By cluepoe in forum Crossfire
    Replies: 0
    Last Post: 01-01-2008, 03:39 AM
  3. Window Blinds?
    By Derek in forum Off Topic
    Replies: 0
    Last Post: 12-06-2006, 08:31 PM
  4. Ads popping up in a new window?!
    By Bwanana in forum Free Hosting
    Replies: 4
    Last Post: 04-24-2006, 10:32 AM
  5. Script Help ( TOS in a pop-up window)
    By darkjetx in forum Graphics & Webdesign
    Replies: 6
    Last Post: 01-22-2006, 05:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers