Support » Fixing WordPress » Dropdown & _blank

  • Hello,

    I’m trying to figure out how to open sites from a dropdown menu in a new browser window (“_blank”).

    Here’s my code:

    <select name="some-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;"> <option value="">Topic</option>
    <option value=""> </option>

    This code opens the address in the same window. But how to open it in a new window?

    Any idea?

    Thanks a lot!

Viewing 5 replies - 1 through 5 (of 5 total)
  • somewhere inside of the opening <a href="....."> tag you need to add “target=”_blank” so it would look something like this;

    <a href="" target="_blank">Anchor Text</a>

    Thank you Trisha –

    but now the most important question… where is this tag in my code? lol

    dumb question so forgive me,…….but where did you get the dropdown code you show above?

    Where does it appear in your site? (Post a link so we can look at it and your source code).

    Also, is this dropdown box created by a function? If so, post the function as well – if it’s created by a function (maybe in your theme’s functions.php file) then that might be where you’ll find the <a href= tag….

    Trisha, thank you again for your reply. Well, this code is the standard code of WP 2.5 (probably earlier versions as well?!).

    You can see the original code when you put your archives as a drop down menu on the sidebar…

    Aha…….you are using a Widget.

    Okay this should work BUT back up your widgets.php file FIRST just in case 😀

    Navigate to your /wp-includes/widget.php file

    At around line 882 you’ll see this code:

    <li><a href="<?php the_permalink() ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?> </a></li>

    Change it to add


    Exactly where I show it here:

    <li><a href="<?php the_permalink() ?>" target="_blank"><?php if ( get_the_title() ) the_title(); else the_ID(); ?> </a></li>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Dropdown & _blank’ is closed to new replies.