How do I get current Javascript url?

Asked

Viewed 50,369 times

8

I am using jQuery. How do I get the path from the current and complete URL, I want to assign it to the variable url_atual.

$("#id_ativo").change(function(){

   $.ajax({
      type: "POST",
      url: url_atual,
      ...
  • To get javascript do this, the rest do not know help you: function sayHello()
{
 var url = window.location.href.toString();
 alert(url);
}

sayHello();

1 answer

19


Try using the code below

var url_atual = window.location.href;
  • How did you make your photo zoom when you hover your mouse over it? I looked for other users and only found you that happens this kkk.

  • @Eduardoribeiro this happens when the user has a "kind of big" display name. You can see that the same happens in the questions/answers of that user.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.