This is a translated page. The original can be found here: http://iwebdevel.com/2009/06/10/javascript-get-anchor-from-url/
UPDATES VIA RSS | Email Ενημέρωση μέσω RSS | Email Get updates via feedburner Get updates via twitter
Home / Apps / Coding / JavaScript & Ajax / PHP / JavaScript: Get anchor from … Αρχική Σελίδα / Apps / Κωδικοποίηση / JavaScript & Αίας / PHP / JavaScript: Πάρτε άγκυρα από την ...

JavaScript: Get anchor from URL JavaScript: Πάρτε άγκυρα από URL

Posted on 10. Καταχωρήθηκε στις 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Ιούνιος, 2009 από Dragos σε Apps, Κωδικοποίηση, JavaScript & Ajax, PHP

To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: Για να πάρει την άγκυρα από ένα URL (αυτό είναι το κείμενο μετά τον χαρακτήρα #) στην JavaScript, μπορείτε να χρησιμοποιήσετε τους ακόλουθους κωδικούς:

 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 url http://iwebdevel.com/some-post # comment = '-1'? / / εάν πρέπει να λάβει την τρέχουσα διεύθυνση URL της χρήσης παράθυρο: var url = window.location? 
 var anchor=url.hash; //anchor with the # character var άγκυρα = url.hash? / / άγκυρα με τον χαρακτήρα # 
 var anchor2=url.hash.substring(1); //anchor without the # character var 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"); var άγκυρα = $ (αυτό). attr ( "hash")? 
Translate this post Μεταφράστε αυτήν την θέση


Related posts: Σχετικές θέσεις:

  1. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Πώς να πάρετε το δείκτη (θέση σε μια ομάδα) ενός αντικειμένου με jQuery;
  2. Javascript: How to validate email address with JavaScript? Javascript: Πώς να επικυρώσετε τη διεύθυνση ηλεκτρονικού ταχυδρομείου με JavaScript;
  3. JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Αποστολή λειτουργεί ως παράμετρος σε μια άλλη λειτουργία (callbacks)
  4. JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Τι γίνεται αν jQuery κινούμενα σχέδια δεν φωτιά / εκκίνηση;
  5. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Πού μπορώ να βρω τα ακίνητα για όλα τα στοιχεία HTML;

    blog comments powered by Disqus blog παρατηρήσεις που κινούνται με Disqus