我有一些javascript和一个允许用户输入搜索字词的表单,然后从sharepoint站点加载带有搜索结果的相应页面...唯一的问题是它在浏览器选项卡上加载结果而我需要它(尝试)在新标签页上打开。
我已经尝试将target =“_ blank”加入到代码中,但似乎无法使其工作。我也看过使用window.open的例子,但是无法弄清楚如何把它合并到我的代码中...任何帮助都将不胜感激
代码是
<script type="text/javascript">// <![CDATA[
// Search for the terms when the Search button is clicked
function customSearch(type,site,scope) {
var searchUrl = "*website link will be here*"
var searchTerm = "&k=" + document.getElementById("searchBox").value;
var listParams = "&cs=This%20" + type + "&u=" + scope;
document.location.href = searchUrl + searchTerm + listParams;
}
// Initiate the customSearch function when the Enter key is pressed
function searchKeyPress(e) {
// look for window.event in case event isn't passed in
if (window.event) { e = window.event; }
if (e.keyCode == 13)
{
document.getElementById('searchButton').click();
}
}
// ]]></script>
<input id="searchBox" onkeypress="javascript:searchKeyPress(event);" type="text" name="searchBox" placeholder="Search SharePoint" />
<input id="searchButton" onclick="javascript:customSearch ( 'List', 'http://server/site', '*website link will be here*' )";" type="button" name="searchButton" value="Search" />
</form>