/ Published in: jQuery
do you want to check a file exists using jQuery ? that's is useful for none server side support servers or static projects or for multi-themes website هذا الكود يفيدك في التحقق من وجود ملف على السيرفر بدون الحاجة للتعامل مع لغة خادم مفيدة جداً للمواقع العادية والتي تستخدم أكثر من ثيم في الموقع
Expand |
Embed | Plain Text
// url like : http://yoursite.com/hello // url like : http://yoursite.com/second var pathArray = window.location.pathname.split('/'); $.ajax({ url: "/css/my_style_"+pathArray[1].toLowerCase()+".css", type:'HEAD', error: function() { $("#colorCss").attr("href","/css/my_style.css"); }, success: function() { $("#colorCss").attr("href","/css/my_style_"+pathArray[1].toLowerCase()+".css"); } });
You need to login to post a comment.
