javascript - Fade in/out page on page load with internal links -
i have script fades in/out page
(function($) { $(window).load(function() { $('#preloader').fadeout(); $('#wrap').fadein(); $("a").click(function(event){ event.preventdefault(); linklocation = this.href; $("#wrap").fadeout(redirectpage); }); function redirectpage() { window.location = linklocation; } }); })(jquery); but have external links don't want effect don't want target these.
i have found how test internal links using script
var siteurl = "http://" + top.location.host.tostring(); var internallinks = $("a[href^='"+siteurl+"'], a[href^='/'], a[href^='./'], a[href^='../'], a[href^='#']"); but i'm stuck on how combine two! ideas please?
i think use regex,
try this,
var patt = new regexp('(\/|..\/|.\/|#|https:\/\/www.google.co.in)'); var $internallinks = []; $('a').each(function(index){ if(patt.test($(this).attr('href'))){ $(this).addclass('fadeclass'); }; }) $('input').click(function(){ $('.fadeclass').fadeout('slow') }); from above code, used regular expression match href, when mentioned external links found added fadeclass. can use fadeclass whatever.
Comments
Post a Comment