有什么方法可以在Json中获取窗口的url。我在下面试过但没有用。 JSON用于显示小部件。以下是代码片段。
CQ.wcm.ContentFinderTab.getResultsBoxConfig({
"itemsDDGroups": [CQ.wcm.EditBase.DD_GROUP_ASSET],
"itemsDDNewParagraph": {
"path": "foundation/components/image",
"propertyName": "./fileReference"
},
"noRefreshButton": true,
"tbar": [
CQ.wcm.ContentFinderTab.REFRESH_BUTTON,
"->",
{
"url": "/bin/wcm/contentfinder/asset/viewnew.json"+window.location.href;
}, {
"baseParams": {
/*"defaultMimeType": "image"*/
"mimeType": "image"
},
"autoLoad":false,
"reader": new CQ.Ext.data.JsonReader({
"totalProperty": "results",
"root": "hits",
"fields": [
"name", "path", "title", "mimeType", "ddGroups", "size", "lastModified", "ck", "templateParams", "imageWidth", "imageHeight"
],
"id": "path"
})
})
由于
答案 0 :(得分:0)
这里没有JSON。只需object literal
您需要从发送的对象中删除尾随分号,并可能添加参数名称。我也会对URL进行编码
{"url": "/bin/wcm/contentfinder/asset/viewnew.json?url="+
encodeURIComponent(window.location.href)
},
如果您只需要哈希,则不需要参数名称和编码
{"url": "/bin/wcm/contentfinder/asset/viewnew.json"+ location.hash},
如果散列中的内容多于您想要的内容,则需要将其拆分
{"url": "/bin/wcm/contentfinder/asset/viewnew.json"+
location.hash.split(".html")[0]+".html"
},
或者确定:
{"url": "/bin/wcm/contentfinder/asset/viewnew.json"+
(location.hash.indexOf(".html")!=-1?location.hash.split(".html")[0]+".html":location.hash)
},