如何将用户搜索查询传递到SharePoint 2013中的提供程序托管应用程序 [英] How to pass user search query to a provider hosted app in SharePoint 2013

查看:76
本文介绍了如何将用户搜索查询传递到SharePoint 2013中的提供程序托管应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将外部系统中存在的搜索功能集成到SharePoint 2013搜索屏幕中。

I want to integrate a search feature present in an external system in to SharePoint 2013 search screen.

理想情况下,当用户搜索我要传递该文本的内容时到提供商托管的应用程序,它将在外部系统上运行真实搜索并显示结果。

So ideally when a user searches for something I want to pass that text to a provider hosted app, which will run the real search on the external system and display the results.

但用户会感觉一切都在一个地方,即。 SharePoint 2013以及人员搜索和内容。

But the user will have the feeling that everything is in one place ie. SharePoint 2013 along with people search and stuff.

谢谢

推荐答案

你可以使用javascript从window.location和window.location.hash中获取它。

You can grab it from window.location and window.location.hash using javascript.

var query = "";
//grab search query string on load
function OnLoad()
{
query = GetQSParameterByName("k");
}

//this function is copied from somewhere on stackoverflow
function GetQSParameterByName(name) {
    name = name.replace(/[[]/,"\[").replace(/[]]/,"\]");
    var regexS = "[\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return decodeURIComponent(results[1].replace(/\+/g, " "));
}

//monitor for and grab search term on ajax update
//using jquery


(document).ready(function ()
{
(document).ready(function() {


(window).on('hashchange',function()
{
query = location.hash.split(" =")[1];
YOURCODE();
});
});

//在此处查询您的外部搜索代码//
功能YOURCODE(){
/ * DO SOMETHING * /
}
(window).on('hashchange', function() { query = location.hash.split("=")[1]; YOURCODE(); }); }); //INSERT CODE TO QUERY YOUR EXTERNAL SEARCH HERE// function YOURCODE() { /* DO SOMETHING */ }


这篇关于如何将用户搜索查询传递到SharePoint 2013中的提供程序托管应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆