【发布时间】:2019-02-01 19:43:11
【问题描述】:
我的 jQuery 代码在新窗口中打开了这个 href。我想在同一个窗口中打开这个 href,但这不起作用。 (切换侧面)
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);
});
【问题讨论】:
-
试试这个
window.open("https://www.youraddress.com","_self") -
试试
window.location.href = url; -
请访问stackoverflow.com/questions/503093/…。希望对您有所帮助。
-
使用
window.location.href=url代码代替`window.open(url);
标签: javascript jquery html