Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 获取JSON内的窗口url_Javascript_Json_Extjs_Aem - Fatal编程技术网

Javascript 获取JSON内的窗口url

Javascript 获取JSON内的窗口url,javascript,json,extjs,aem,Javascript,Json,Extjs,Aem,有没有办法在Json中获取窗口的url。我在下面试过,但不起作用。 JSON用于显示小部件。下面是代码片段 CQ.wcm.ContentFinderTab.getResultsBoxConfig({ "itemsDDGroups": [CQ.wcm.EditBase.DD_GROUP_ASSET], "itemsDDNewParagraph": { "path": "foundation/components/ima

有没有办法在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)
},

你想干什么?将url添加到文件本身?什么是“inside JSON”意思-显示更多代码实际上这是回调,希望以窗口url作为请求参数来点击servlet。当您指的是窗口的url时,您是只想要内容的路径还是整个url。我的意思是
/content/xyz/something.html
http://somedomain.com/cf#/content/xyz/something.html
?如果获得完整路径,我只需要/content/xyz/something.html,或者不需要任何问题。好的,我已经删除了分号,但它仍然不起作用。显示“url”的我的页面源“/bin/wcm/contentfinder/asset/viewnew.json”+window.location.href而不是window.location.hrefWhat页面源的值?getResultsBoxConfig需要获取URL并对其进行处理。Hi encodeURIComponent(window.location.hash)似乎解决了问题,它给了我以下结果localhost:4502/bin/wcm/contentfinder/asset/viewnew.json%23%2Fcontent%2FCompany%2Fen%2facture.html?\u dc=1403269699278&query=&mimeType=image&\u但我不想要编码格式。只需查找content/Company/en/Article.html。因此,请使用第二个版本,不带编码