WordPress.org

Ready to get started?Download WordPress

Forums

Would like custom menu option (url) to open in a new window (19 posts)

  1. djhomick
    Member
    Posted 3 years ago #

    I am using Custom Menus to create an item (url) that points to an exterkal link, and I would like it to open in a new window. Is that possible?

  2. stvwlf
    Member
    Posted 3 years ago #

    At the top of the Custom Menus dashboard page click Screen Options.

    Put a check in Link Target and CSS classes (not needed for what you want but good to have visible anyway). Now a Link Target field is added to every menu item that you can set to open in a new window.

  3. djhomick
    Member
    Posted 3 years ago #

    Thanks, that sounds perfect. However, I did what you said and the drop down appeared for my menu option, I set it to open in new window, saved the menu, but it did not work. Tried it in IE & FF. A view of source code shows no target in the A tag. Am I missing something? Have you actually seen this work?

    WP 3.1 and everything up to date.

  4. stvwlf
    Member
    Posted 3 years ago #

    hi

    Yes, I have done this in 3.0.5 and it worked. I just sent it up on a test site in 3.1 and it also worked, both for a WordPress page on the site and for an external link. I see target="_blank" in View Source. This is working in IE FF Chrome.

    Are you positive the theme is using the custom menu and is not falling back to wp_list_pages or wp_page_menu? When using View Source the classes on each menu LI should be like: menu-item menu-item-type-post_type menu-item-object-page menu-item-123 - starting with "menu-item". If not, its not using the custom menu. I'd start by confirming that is working.

  5. djhomick
    Member
    Posted 3 years ago #

    D'oh! I was changing it on a sub-menu and testing it from the main menu. Sorry about that, but Thanks LOADS for the solution. It is just what I needed.

  6. nancy22314
    Member
    Posted 3 years ago #

    I am having this same issue. Mine is a sub menu item on the drop down. I added Link Target and CSS classes as suggested. When I edit the item it now has a place to chose "new window or tab" or "same window and tab". I chose the new. Saved the menu. refreshed the page. no luck and it's not in the source. What could be the problem?

  7. stvwlf
    Member
    Posted 3 years ago #

    For starters refresh the page in your browser a few times <CTRL> + R to make sure you are seeing the latest version and not a browser cached version.

    If that's not it double check everything you did because what you said you did is what you are supposed to do.

    If you still can't find it, as I said originally

    Are you positive the theme is using the custom menu and is not falling back to wp_list_pages or wp_page_menu? When using View Source the classes on each menu LI should be like: menu-item menu-item-type-post_type menu-item-object-page menu-item-123 - starting with "menu-item". If not, its not using the custom menu. I'd start by confirming that is working.

    Check View Source and confirm the theme is using the custom menu.

  8. djhomick
    Member
    Posted 3 years ago #

    If you happen to be using iThemes Builder, you have to edit the Navigation Module in each Layout to tell it to use a custom menu. Just a thought. :-)

  9. Priyanka Shitole
    Member
    Posted 3 years ago #

    I have same issue. I checked my source code: <li id="menu-item-273" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-273">Account Login

    But this does not open in new tab/window. I am using WordPress 3.2.1

    Please advice.
    Thank you.
    Priyanka

  10. stvwlf
    Member
    Posted 3 years ago #

    Hi Priyanka

    At the top of the Custom Menus dashboard page click Screen Options.

    Put a check in Link Target and CSS classes. Now a Link Target field is added to every menu item. Set the ones you want to "open in a new window".

  11. Priyanka Shitole
    Member
    Posted 3 years ago #

    Hi,

    I have already done that. But its not opening in new window/tab. I do see target="_blank" in source code.

    Please advice.

    Thank you.
    Priyanka

  12. stvwlf
    Member
    Posted 3 years ago #

    Is that happening in more than one browser, and on more than one computer?

  13. Priyanka Shitole
    Member
    Posted 3 years ago #

    I tried Mac OS, Windows XP and Vista. I tried it on FF, IE, Safari and Chrome.

  14. stvwlf
    Member
    Posted 3 years ago #

    Perhaps there is some javascript overriding the intent of opening in a new tab/window? Can you post a URL of the page with this issue?

  15. Priyanka Shitole
    Member
    Posted 3 years ago #

    May be. Is there any particular java-script i should be looking for? Unfortunately, I can't share the url. Its for a client. But I would really appreciate any insight on this issue.

    Thank you.
    Priyanka

  16. stvwlf
    Member
    Posted 3 years ago #

    target="_blank" is standard HTML.

    If you use it, it opens links in a new window or tab, no question, that is how it works. Someone can configure a browser to override that action, so the browser doesn't open it in a new tab or window. That is why I asked you if this is happening on more than one browser.

    Your answer was it happens in every browser on every operating system. That eliminates browser settings as a possible cause.

    Since this is not happening on any browser on any computer something is overriding this normal HTML action. A likely source of it is javascript or jQuery code.

    Without knowing a URL, where I could see the code that is running, its not possible to tell you what code is causing this, or even if this is the cause. You will have to look at the code in your theme and look for yourself.

    One way to override target="_blank" would be to either change the target to something else on all occurrences of `target="_blank". Another would be to simply remove that attribute altogether. If this was done in jQuery, the code would likely start with
    .attr('target' or .attr("target"
    However there are many ways it could be done, not just with that code and not just in jQuery.

    I can't really help you beyond this given the information you are able to post. You have to review all of your code. Try disabling any javascripts one at a time and see if the links start opening in new tabs/windows.

    If you don't already use it, download and install the Firefox Firebug addon. That is how I'd review your code if I was looking at your site.

  17. Priyanka Shitole
    Member
    Posted 3 years ago #

    Can I email you the link?

  18. stvwlf
    Member
    Posted 3 years ago #

    You can email me the link as long as you understand I am not guaranteeing I will find your problem.

  19. mazharahmad
    Member
    Posted 2 years ago #

    Please visit be below link for the solution

    http://dev.studiopress.com/nav-new-window.htm

Topic Closed

This topic has been closed to new replies.

About this Topic