JavaScript: Get anchor from URL جافا سكريبت : احصل على مرساة من رابط
Posted on 10. نشر في 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP يونيو ، 2009 من قبل دراكوش في تطبيقات ، الترميز ، جافا سكريبت واياكس ، [فب]
To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: للحصول على مرساة من رابط (وهذا هو النص بعد الحرف #) في جافا سكريبت يمكنك استخدام التعليمات البرمجية التالية :
var url='http://iwebdevel.com/some-post#comment-1'; //if you need to take the current url of the window use: var url=window.location; var anchor=url.hash; //anchor with the # character var anchor2=url.hash.substring(1); //anchor without the # character رابط فار = '# http://iwebdevel.com/some-post تعليق - 1' ؛ / / اذا كنت بحاجة الى اتخاذ عنوان الموقع الحالي لاستخدام نافذة : فار رابط = window.location ؛ فار مرساة = url.hash ؛ / / مرساة مع # فار الطابع anchor2 = url.hash.substring (1) ؛ / / دون مرساة الطابع # If you're iterating through the links in a page with JQuery, and $(this) defines a single link, then to find the anchor of this object you'd need to use the following code: إذا كنت بالتكرار عبر وصلات في صفحة مع JQuery ، ودولار (هذا) ويحدد وجود صلة واحدة ، ثم العثور على مرساة لهذا الكائن كنت بحاجة إلى استخدام التعليمات البرمجية التالية :
var anchor=$(this).attr("hash"); مرساة فار = دولار (هذا). attr ( "التجزئة") ؛ Related posts: الوظائف ذات الصلة :
- JavaScript: How to get the index (position within a group) of an object with jQuery? جافا سكريبت : كيفية الحصول على مؤشر (الموقف داخل مجموعة) للجسم مع jQuery؟
- Javascript: How to validate email address with JavaScript? جافا سكريبت : كيفية التحقق من صحة عنوان البريد الإلكتروني مع جافا سكريبت؟
- JavaScript: Send function as a parameter to another function (callbacks) جافا سكريبت : إرسال الدالة كمعلمة إلى وظيفة أخرى (رد)
- JavaScript: What if jQuery animation doesn't fire/start? جافا سكريبت : ماذا لو الرسوم المتحركة jQuery لا النار / تبدأ؟
- JavaScript: Where do I Find All Properties for All HTML Elements ? جافا سكريبت : أين يمكنني إيجاد جميع خصائص لجميع عناصر أتش تي أم أل؟












































