0

My jQuery code opened this href in new window. I would like to open this href in the same window, but this is not working. (Toggle the side)

jQuery('.dig-pub').on('click', function() {
  url = jQuery(this).parent().find('a').attr('href');

  // Remove this (opens new window)
  window.open(url);

  // Use below to open link in the same window
  //$(location).attr(url);

});

https://codepen.io/Kidkie/pen/gdaJjZ

JsStorm2
  • 75
  • 6

1 Answers1

0

In fact to open the url in the same window you does to use the window.location like that :

                jQuery('.dig-pub').on('click', function() {
                    url = jQuery(this).parent().find('a').attr('href');
                            window.location.href = url;
                                    });
Gokul
  • 68
  • 1
  • 2
  • 13
Inazo
  • 488
  • 4
  • 15