If this is all that you're using jQuery for, I would suggest avoiding any
library at all. Just do a simple onload listener or, if you really don't
want to wait for that, put the code block at the very end of the body
element, right before the closing </body> tag. For what you're trying to
do, the DOM will be available at that point. Then, you can call this code,
which is entirely DOM-based.

function outsideLinksToNewTab(){
  var els = document.getElementsByTagName('a'),
  rea = /^http:\/\//i,
  reb = /^http:\/\/www.cyberindia.in\//i;
  for(var i=0; els && i<els.length; i++){
    var el = els[i],
    href = el.getAttribute('href');
    if(href.match(rea) && !href.match(reb)){
      el.setAttribute('target', '_blank');
    }
  }
}

jg





On Wed, Jul 2, 2014 at 5:23 AM, Pritam Mandal <sunnypri...@gmail.com> wrote:

> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
> "></script>
> <script async type="text/javascript">
> jQuery(document).ready(function () {
> jQuery('a[href*="http://"]:not([href*="http://www.cyberindia.in/";])').attr("target",
> "_blank");
>     });
> </script>
>
>
> I am *using the above code* but it's *heavy* and on* gtmetrix
>  ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
> <http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js> showing
> that it's not parsed.*
>
> I want to use http://minifiedjs.com/download/minified.js which is light
> weight and parsed but can't frame the below code to work.
>
>
> <script async type="text/javascript">
> jQuery(document).ready(function () {
> jQuery('a[href*="http://"]:not([href*="http://www.cyberindia.in/";])').attr("target",
> "_blank");
>     });
> </script>
>
> Basically I want when a out-going link (external link) is clicked on the
>> website it will open in a new window. Please help.
>
>
> *Thanks in advance :)*
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Google AJAX APIs" group.
> To post to this group, send email to
> google-ajax-search-api@googlegroups.com
> To unsubscribe from this group, send email to
> google-ajax-search-api+unsubscr...@googlegroups.com
> To view this message on the web, visit
>
> https://groups.google.com/d/msgid/google-ajax-search-api/4465bb15-60f3-4df6-b7e9-9a78eb4076f8%40googlegroups.com
> <https://groups.google.com/d/msgid/google-ajax-search-api/4465bb15-60f3-4df6-b7e9-9a78eb4076f8%40googlegroups.com?utm_medium=email&utm_source=footer>
> For more options, visit this group at
> http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Google AJAX APIs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-ajax-search-api+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Jeremy R. Geerdes
Generally Cool Guy
Des Moines, IA

If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan
Church!
http://www.debraheightswesleyan.org

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Google AJAX APIs" group.
To post to this group, send email to
google-ajax-search-api@googlegroups.com
To unsubscribe from this group, send email to
google-ajax-search-api+unsubscr...@googlegroups.com
To view this message on the web, visit
https://groups.google.com/d/msgid/google-ajax-search-api/CAF4cwg8P0eYC0H%3DyH3VfoTtbMSCXNQB00GgcuybLVvBse28%3DUg%40mail.gmail.com
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"Google AJAX APIs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-ajax-search-api+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • How to Pritam Mandal
    • Re: How to Jeremy Geerdes

Reply via email to