描述DIL.tools
命名空间中的方法。 这些实用程序功能可帮助您执行特定任务。
返回用于访问当前页面的搜索词。
getSearchReferrer
的用途在DIL中,getSearchReferrer
返回用于访问您的网站的搜索结果(名称和关键词)。 默认情况下,您可以将特定搜索词传递到此函数,或者允许其针对document.referrer
搜索支持的搜索引擎(AOL、Ask、Bing、Google和Yahoo)。
函数签名:DIL.tools.getSearchReferrer(uri, initConfig)
getSearchReferrer
接受:
{string}
: (可选) 包含搜索URL的字符串(如果未定义, document.referrer
则使用)。{object}
: (可选) 包含、或配置 hostPattern
的 queryParam
对象 queryPattern
。和返回:
{object}
包含有效名称和关键字的对象。搜索类型 | 描述 | 代码示例 |
---|---|---|
默认搜索 | 返回AOL、Ask、Bing、Google和Yahoo搜索引擎使用的关键词搜索词。 |
var results = DIL.tools.getSearchReferrer();
|
在自定义URL中传递 | 根据自定义URL返回搜索反向链接。 |
var results =
DIL.tools.getSearchReferrer("https://www.ehow.com/search.aspx?q=adobe+rules");
|
将URL主机名与自定义正则表达式匹配 | 在自定义正则表达式中传递,以匹配引荐URL的主机名。 |
var results =
DIL.tools.getSearchReferrer("https://www.ehow.com/
search.aspx?q=adobe+rules",{
hostPattern:/ehow\./,
queryParam:"p"
});
|
使用自定义正则表达式匹配搜索模式 | 在自定义正则表达式中传递以执行自定义搜索。 |
var results =
DIL.tools.getSearchReferrer("https://www.ehow.com/search.aspx?q=adobe+rules,
{
hostPattern:/ehow\./,
search_pattern:/[&\?]p=([^&]+/
});
|
将统一资源标识符(URI)分解为其组成组件:hash
、host
、href
、pathname
、protocol
、search
和uriParams
。
函数签名:DIL.tools.decomposeURI
decomposeURI
接受:
uri {string}
: (可选) 包含URI的字符串。如果未指定,则默认为document.location.href
。和返回:
{object}
:包含有效名称和关键字的对象。var uriData = DIL.tools.decomposeURI('https://www.adobe.com/?arg1=123&arg2=456#am');
{
hash : "#am",
host : "www.adobe.com",
hostname : "www.adobe.com",
href : "https://www.adobe.com/?arg1=123&arg2=456#am",
pathname : "",
protocol : "https:",
search : "?arg1=123&arg2=456",
uriParams : {
arg1 : "123",
arg2 : "456"
}
}
搜索在网页的元标记中定义的特定内容,并在对象中返回该数据。
函数签名:DIL.tools.getMetaTags( 1 or more parameters)
getMetaTags
接受要搜索的一个或多个名称参数(字符串类型)。它返回由键值对组成的对象。
var dataLib = DIL.create({
partner: 'partnerName',
containerNSID: containerNSID
});
dataLib.api.signals(DIL.tools.getMetaTags('application', 'keywords', 'description'), 'c_').submit();
var dataLib = DIL.create({
partner: `partnerName',
containerNSID: containerNSID
});
dataLib.api.signals(DIL.tools.getMetaTags('application','keywords', 'description'), 'c_').submit();