在JSON中获取窗口url
Get window url inside JSON
是否有办法在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"
})
})
谢谢
这里没有JSON。只是一个对象文字
您需要从您发送的对象中删除末尾的分号,并可能添加一个参数名。我还将对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)
},
相关文章:
- 按下一个HTML按钮,该按钮使用一个功能在同一个新窗口中打开URL
- asp.net MVC,重定向到视图,视图打开新窗口到外部url,它'It’’’’我们被当成一种风景
- javascript在退出时打开窗口url
- JavaScript 窗口.URL 在函数中未定义
- 如何从父窗口访问子窗口 URL
- 向右滑动一个图像,同时打开一个超时的新窗口url
- 如何使用javascript从父窗口获取子窗口url
- 更改每个不同选项卡的窗口URL
- 获取顶部窗口url从框架/iframe在不同的域
- 隐藏窗口.URL位置
- 当我们没有子窗口url时,如何知道子窗口已关闭
- 如何在弹出窗口url中使用具有$ sign的变量
- 在JSON中获取窗口url
- 保存当前窗口URL,并在几次导航后移回该URL
- 如何获取当前窗口URL并使用它
- Javascript新窗口URL中的回车/换行
- 如何从 Firefox 插件中的“编辑此书签”弹出窗口中获取窗口 URL
- 如何从Iframe获得父窗口URL
- 窗口.URL未定义
- Iframe表单提交数据到窗口URL