替代不打开新标签| javascript | window.open

时间:2015-03-27 14:57:31

标签: javascript html

我今天正在这样做,但不希望它打开一个新标签。我希望它使用相同的页面:

<td>
            <form>
            <select name="URL" onchange="window.open(this.value);">
                <option selected="selected" value="">...</option>
                <option value="ListArchivedProjects">List archived projects</option>
                <option value="ListArchivedCertificates">List archived certificates</option>
                <option value="SelectProject">List Projects</option>
                <option value="ListCertificates">List Certificates</option>
                <option value="AddProjectForm.jsp">+ Add new project</option>
                <option value="AddCertificateForm.jsp">+ Add new certificate</option>
            </select>
            </form>
        </td>

2 个答案:

答案 0 :(得分:1)

在同一页上?

location.href = this.value;

答案 1 :(得分:1)

        <td>
        <form>
        <select name="menu1" id="menu1">
            <option selected="selected" value="">...</option>
            <option value="ListArchivedProjects">List archived projects</option>
            <option value="ListArchivedCertificates">List archived certificates</option>
            <option value="SelectProject">List Projects</option>
            <option value="ListCertificates">List Certificates</option>
            <option value="AddProjectForm.jsp">+ Add new project</option>
            <option value="AddCertificateForm.jsp">+ Add new certificate</option>
        </select>
          <script type="text/javascript">
              var urlmenu.onchange = function() {
              window.open( this.options[ this.selectedIndex ].value, '_self');
               };
        </script>
        </form>
    </td>