WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] target="_blank" for a page on menu? (56 posts)

  1. Bhavadasa
    Member
    Posted 2 years ago #

    I've created a discussions board, and a page on the menu with the same address. It works well. However, rather than loading in a new tab (keeping the webpage open), it loads in the same tab.

    Is there a php, or somewhere I can add target="_blank" to the address?

    Thanks!

  2. Andrew
    Forum Moderator
    Posted 2 years ago #

    Ooops misread, I'll post something more sensible

  3. Bhavadasa
    Member
    Posted 2 years ago #

    Yikes. Lost me. Can you give me a little direction?

  4. Andrew
    Forum Moderator
    Posted 2 years ago #

    There should be a section either within the PHP that's constructing the hyperlink, which you can add target="_blank" to the link.

    Do you know which file holds this?

  5. Bhavadasa
    Member
    Posted 2 years ago #

    No, that's part of my problem. I've scanned a number of php files, but can't find that (discussions) address anywhere.

    Years ago, I had a website that I was able to find the menu with "Home" in it. Then next to it (for another page) I simply added the url with target="_blank" -- and it worked. But, I'm not having such luck now.

  6. Bhavadasa
    Member
    Posted 2 years ago #

    On "View Page Source" I find the below code . (it appears differently when posted here). But where do I find it, to edit?

    <body>
    <div id="page2">
    <div id="header">
    <div class="logo_resize">
    <div class="logo">
    <h1>
    Saranagati Village Inc.
    </h1>
    <small class="slogan">
    The Official Website of the Board of Directors for SVHI </small></div>
    <!-- /logo-->
    <div class="topnav">
    <ul class="menusm">
    <li class="page_item page-item-27 current_page_item">Home
    <li class="page_item page-item-32">Blog
    <li class="page_item page-item-136">Discussions
    <li class="page_item page-item-126">Membership
    <li class="page_item page-item-40">Contact

    </div>
    <!--/topnav -->
    </div>

  7. Andrew
    Forum Moderator
    Posted 2 years ago #

    Okay, in that code (above),
    could you repost it in the code tags (otherwise the hyperlink wont show up properly, as you can see there's no <a> tags).

    Then could you say which hyperlink you want to have a target blank?

  8. Bhavadasa
    Member
    Posted 2 years ago #

    This system isn't allowing the coding to post as it appears in "view page source". I'll try the hyperlink....

    It's line #136:> Discussions:

  9. Bhavadasa
    Member
    Posted 2 years ago #

    a href="http://www.saranagativillage.com/discussions/"

  10. Andrew
    Forum Moderator
    Posted 2 years ago #

    Are you using the

    code
    button (just above this text box when replying) to wrap your code?

  11. Bhavadasa
    Member
    Posted 2 years ago #

    This is the "index" page, right? Where do I find it as it appears "view page source"? I've looked in the "index.php, but no sign of it. Hmmm...

  12. Bhavadasa
    Member
    Posted 2 years ago #

    Using the code button? No.

  13. Bhavadasa
    Member
    Posted 2 years ago #

    Sorry about that!

    <body>
    <div id="page2">
    <div id="header">
      <div class="logo_resize">
        <div class="logo">
          <h1><a href="http://www.saranagativillage.com" title="Saranagati Village Inc. - The Official Website of the Board of Directors for SVHI">
            Saranagati Village Inc.        </a></h1>
          <small class="slogan">
          The Official Website of the Board of Directors for SVHI      </small></div>
        <!-- /logo-->
        <div class="topnav">
          <ul class="menusm">
            <li class="page_item page-item-27 current_page_item"><a href="http://www.saranagativillage.com/">Home</a>
    <li class="page_item page-item-32"><a href="http://www.saranagativillage.com/blog/">Blog</a>
    <li class="page_item page-item-136"><a href="http://www.saranagativillage.com/discussions/">Discussions</a>
    <li class="page_item page-item-126"><a href="http://www.saranagativillage.com/membership/">Membership</a>
    <li class="page_item page-item-40"><a href="http://www.saranagativillage.com/contact/">Contact</a>
    
        </div>
        <!--/topnav -->
      </div>
  14. Andrew
    Forum Moderator
    Posted 2 years ago #

    Instead of fishing through the page for it, you could use jQuery to add the target of blank to your menu item.

    You said you want it for Discussions?
    Assuming the Discussions link will start with http://

    $('.topnav a[href^="http://"]').attr('target','_blank');
  15. Bhavadasa
    Member
    Posted 2 years ago #

    Ok. Sorry, this is a little bit above me...

    I don't know how to use jQuery
    Where would I find that specific code?
    I assume that I would insert the address after "http://. Correct?

  16. Andrew
    Forum Moderator
    Posted 2 years ago #

    In the admin panel,
    Go to
    - Appearance
    - Editor

    on the right hand side, look at Templates section
    - find footer.php
    - click on footer

    - paste this above </body>

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script type="text/javascript">
    $('.topnav a[href^="http://"]').attr('target','_blank');
    </script>

    ------

    I assume that I would insert the address after "http://. Correct?

    Correct but only in the navigation menu. Are there some links (that start with http) you don't want to add target of blank?

  17. Bhavadasa
    Member
    Posted 2 years ago #

    Thanks for your patients!

    Ok, I inserted the code. However, it seems to have canceled out the "Piecemaker Slider", and the menu disappeared.

    http://www.SaranagatiVillage.com

  18. Andrew
    Forum Moderator
    Posted 2 years ago #

    Instead try
    $('li.page_item page-item-136 a').attr('target','_blank')

  19. Bhavadasa
    Member
    Posted 2 years ago #

    I replaced it. However, the page remained as I described it above. So, I uploaded a fresh copy of footer.php--still no change. Then I cleared the cache. Again, no change.

    It's a new site under construction, so no problem. Is it something I have done?

    Here's how I put it (did the space cause the problem?):

    <?php wp_footer(); ?>
    
    $('li.page_item page-item-136 a').attr('target','_blank')
    
    </body>
  20. Andrew
    Forum Moderator
    Posted 2 years ago #

    Sorry, you need this

    <?php wp_footer(); ?>
    
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script type="text/javascript">
    $('li.page_item page-item-136 a').attr('target','_blank')
    </script>
    
    </body>
  21. Bhavadasa
    Member
    Posted 2 years ago #

    Nope. That didn't do it either. Sorry to be a pain.

  22. Andrew
    Forum Moderator
    Posted 2 years ago #

    yes sorry I've just edited that post
    to this

    <?php wp_footer(); ?>
    
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script type="text/javascript">
    $('li.page_item page-item-136 a').attr('target','_blank')
    </script>
    
    </body>
  23. Bhavadasa
    Member
    Posted 2 years ago #

    You're probably wishing about now, that you never responded to my post, eh?

    Unfortunately, that didn't do it either. However, I did notice behind the images that something seemed to happen.

    I can reinstall the theme--no problem. I don't want to waste your time on
    this issue (the slider).

    I don't want you to get burnt out!

    I still need the _blank to work.

    What do you think?

  24. Andrew
    Forum Moderator
    Posted 2 years ago #

    Try

    <?php wp_footer(); ?>
    
    <script type="text/javascript">
    $('li.page_item page-item-136 a').attr('target','_blank')
    </script>
    
    </body>
  25. Bhavadasa
    Member
    Posted 2 years ago #

    Nope.

  26. Andrew
    Forum Moderator
    Posted 2 years ago #

    Oh dear I've failed miserably,
    try this,

    <?php wp_footer(); ?>
    
    <script type="text/javascript">
    $('li.page_item.page-item-136 a').attr('target','_blank')
    </script>
    
    </body>
  27. Bhavadasa
    Member
    Posted 2 years ago #

    Well! The slider still isn't working.....

    But... _blank WORKS!!! Fantastic!

    So what do you think I should do about the slider? Reinstall the theme, wp, or... and then come back to the footer.php, and reinsert the correct code above?

  28. Andrew
    Forum Moderator
    Posted 2 years ago #

    No need to reinstall,

    This code in the footer.php file
    <script type="text/javascript" src="/wp-content/plugins/contact-form-7/includes/js/scripts.js?ver=3.2.1"></script>

    Needs to be above this code
    <script type="text/javascript" src="/wp-content/themes/framerate/framerate/js/coin-slider.min.js"></script>
    in the header.php file

  29. Bhavadasa
    Member
    Posted 2 years ago #

    Hmmmm...

    <script type="text/javascript" src="/wp-content/themes/framerate/framerate/js/coin-slider.min.js"></script>

    isn't in the header.php file.

  30. Andrew
    Forum Moderator
    Posted 2 years ago #

    could you post me your header.php file and I'll point you in the direction where you need to place it.

Topic Closed

This topic has been closed to new replies.

About this Topic