0

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:

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?

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
  • 1
    Search for Target blank – Jorawar Singh Aug 16 '16 at 10:22
  • Possible duplicate of http://stackoverflow.com/questions/21045244/programmatically-open-html-link-in-new-tab – Arathi Sreekumar Aug 16 '16 at 10:23
  • @MrJSingh, not its not duplicate like that.. bacause he wants ro submit form in new page. – Haresh Vidja Aug 16 '16 at 10:47
  • @ArathiSreekumar, this id for submit form in new page, not open link in new page. – Haresh Vidja Aug 16 '16 at 10:48
  • The answer there answers this problem. If you read the question it says form submit/link. Hence applicable to both. The question does not need to be phrased exactly as here, but if the context explains it, then its similar enough to be a duplicate. I have only said possible duplicate. It's left up to the moderators to decide. – Arathi Sreekumar Aug 16 '16 at 10:56
  • Possible duplicate of [Opening new window/tab without using \`window.open\` or \`window.location.href\`](http://stackoverflow.com/questions/11735889/opening-new-window-tab-without-using-window-open-or-window-location-href) – maxhb Aug 16 '16 at 15:35

1 Answers1

0

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

$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();\">";
Haresh Vidja
  • 8,340
  • 3
  • 25
  • 42