Search code examples
javascripturlparametersarea

Javascript using Parameter from URL


i have a Problem my Area Shape href="/kosmetikstudios/deutschland/Bayern" tag look so. And i will to use the Parameter "Bayern" (this is the last parameter of the url).

I need this dynamic.

Here are my Javascript Code:

<script type="text/javascript">
  $(document).ready(function(){
  var mName="passiv";
    $("#map area").mouseenter(function(){

      mName = $(this).attr("href"); // i don't have idea to implement this
      bName="images/" +mName + ".png";
      $("#map img").attr("src",bName);

    });

    $("#map area").mouseleave(function(){
      bName="images/Europa.png";
      $("#map img").attr("src",bName);

    });

  });
</script>

Here are my HTML Code

 <area shape="poly" coords="356,300,355,299,354,298....." href="/kosmetikstudios/deutschland/Bayern" title="Kosmetikstudios in Bayern" alt="Kosmetikstudios in Bayern" />

<area shape="poly" coords="156,200,425,699,154,298....." href="/kosmetikstudios/deutschland/Berlin" title="Kosmetikstudios in Berlin" alt="Kosmetikstudios in Bayern" />

I hope anybody can help me.

Regards,

Dave


Solution

  • mName = this.href.substring(
        this.href.lastIndexOf('/') + 1
    );