title: Google Script to open URL in same window as Spreadsheet
body: <p>I'm trying to work around the lack of API for Google Spreahsheet's Filter Views, by passing the filter view's URL into a hyperlink displayed in a sidebar.  </p>
  
  <p>Importantly: I want the filter view URL to open <strong>in the same window</strong> as, and thus replace, the spreadsheet. The hyperlink target should then be <code>_self</code></p>
  
  <pre><code>function listFilterViews(){
    var uiInstance = UiApp.createApplication()
        .setTitle('Teacher Views');
    var panel = uiInstance.createVerticalPanel();
    panel.setSpacing(5)
    var scroll = uiInstance.createScrollPanel();
    scroll.setHeight("100%")
    var url = "https://docs.google.com/blablabla"
    var link = uiInstance.createAnchor("click me", url)
    link.setTarget("_self")
    panel.add(link);
    scroll.add(panel)
    uiInstance.add(scroll);
    SpreadsheetApp.getUi().showSidebar(uiInstance);
  }
  </code></pre>
  
  <p>However, the URL doesn't open in the same window as expected but in an other window instead. How can I fix this?</p>