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
  • #32428

    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.


    ** SOLVED **
    I used ParseUri function available in

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