Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Ajax and WordPress

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #32428
    shazdeh
    Member

    I’m using jQuery to select internal links and do cool ajax stuff.
    $(‘a[href^=”‘+ base_url +'”])
    This works fine, but what if we link to external resources? Like jpeg or pdf’s hosted on our site? It breaks. So I added this to the selector:
    $(‘a[href^=”‘+ base_url +'”]:not(a[href$=”jpg”]):not(a[href$=”jpeg”]):not(a[href$=”gif”]):not(a[href$=”png”])’)
    It’s ugly and it doesn’t cover all extensions. How can I use JavaScript to detect it’s an external file and should not be ajaxed? And not all extensions, for example I may build a .php file and link to that. It’s just a regular page.

    #50053
    shazdeh
    Member

    ** SOLVED **
    I used ParseUri function available in http://blog.stevenlevithan.com/archives/parseuri

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.