使用Javascript在新标签页中打开URL

时间:2022-09-22 18:13:31

I'm having av Wordpress site where I use the plugin "Flexi Pages Widget" to load pages from a dropdown jump menu. I'm not able to modify the javascript to open the URL's in a new tab. I have located the function that open the URL's:

我正在使用AVpress网站,我使用插件“Flexi Pages Widget”从下拉跳转菜单加载页面。我无法修改javascript以在新标签中打开URL。我找到了打开URL的函数:

public function get_dropdown() {
        $dropdown = "<form action=\"". get_bloginfo('url') ."\" method=\"get\">\n<select name=\"page_id\" id=\"page_id\" onchange=\"top.location.href='".get_bloginfo('url')."?page_id='+this.value\">";
        $dropdown .= $this->dropdown_items($this->pages);
        $dropdown .= "</select><noscript><input type=\"submit\" name=\"submit\" value=\"".__('Go', 'flexipages')."\" /></noscript></form>";
        return $dropdown;
    }

How do I modify the function to open the URL's in a new tab?

如何在新选项卡中修改功能以打开URL?

1 个解决方案

#1


0  

Add target="_blank" in form tag and add id and change onchange event of dropdown

在表单标记中添加target =“_ blank”并添加id并更改下拉列表的onchange事件

$dropdown = "<form id="my_custom_form" action=\"". get_bloginfo('url') ."\" target="_blank" method=\"get\">\n<select name=\"page_id\" id=\"page_id\" onchange=\"document.getElementById('my_custom_form').submit();\">";

#1


0  

Add target="_blank" in form tag and add id and change onchange event of dropdown

在表单标记中添加target =“_ blank”并添加id并更改下拉列表的onchange事件

$dropdown = "<form id="my_custom_form" action=\"". get_bloginfo('url') ."\" target="_blank" method=\"get\">\n<select name=\"page_id\" id=\"page_id\" onchange=\"document.getElementById('my_custom_form').submit();\">";