当前位置:优学网  >  在线题库

在同一选项卡中打开链接

发表时间:2022-07-26 02:57:52 阅读:103

如何让这段代码中的链接在同一个选项卡/窗口中打开?

$logo = apply_filters('avf_logo', $logo);
if(is_numeric($logo)){ 
    $logo = wp_get_attachment_image_src($logo, 'full');
    $logo = $logo[0];
}
$logo = "<img {$dimension} src='{$logo}' alt='{$alt}' />";
$logo = "<$headline_type class='logo'><a href='https://www.stejk.se/bbq-aurora-tour'>".$logo."$sub</a></$headline_type>";
}
🎖️ 优质答案
  • 在同一窗口中打开链接有两种方法

    Method 1

    您可以添加target="u self"inside&lta&gt`标记.

    $logo = apply_filters('avf_logo', $logo);
    if(is_numeric($logo)){ 
        $logo = wp_get_attachment_image_src($logo, 'full');
        $logo = $logo[0];
    }
    $logo = "<img {$dimension} src='{$logo}' alt='{$alt}' />";
    $logo = "<{$headline_type} class='logo'><a href='https://www.stejk.se/bbq-aurora-tour' target='_self'
    >{$logo}{$sub}</a></{$headline_type}>";
    

    Method 2

    使用Javascript

    添加将此添加到您的&lta&gt标记`onclick=&quot窗口.打开(this.href,_self)&quot

    
    $logo = apply_filters('avf_logo', $logo);
    if(is_numeric($logo)){ 
        $logo = wp_get_attachment_image_src($logo, 'full');
        $logo = $logo[0];
    }
    $logo = "<img {$dimension} src='{$logo}' alt='{$alt}' />";
    $logo = "<{$headline_type} class='logo'><a href='https://www.stejk.se/bbq-aurora-tour' onclick='window.open(this.href, _self)'
    >{$logo}{$sub}</a></{$headline_type}>";
    
  • 相关问题