1

I am using window.parent.location.href by which i am able to achieve the current page(https://stackoverflow.com/questions/ask) complete url but my intention is to get the uuid of that page which is present in other url i.e (https://stackoverflow.com/questions/ask/id=_abcdes123)

var parentLink = (window.parent.location.href).toString();
if (parentLink.includes("play")) {

projectAreaContextId = '_FpM0wL8DEeOhU53HggnQSg';  //uuid for play
} else if(parentLink.includes("complay")) {
    projectAreaContextId = '_t44MZaySEeSZm-Ey-wkoZw';   //uuid for complay
}

if you see my above code what i am trying is to get the current page url dynamically but projectareacontextid is hardcoded which i want to get dynamically as well but as i mentioned the uuid of the project area is not present in the current page url but in next page url, so is there any way to achieve so, also is there any rest api to get project area uuid?

  • You can not get dynamically the URL of the next page - it is unpredictable because it depends on the user's interaction. You can however include the UUID somewhere inside your HTML markup while you render your current page - then you can simply search the DOM for the given string. – IVO GELOV Apr 29 '20 at 07:02
  • @IVO GELOV but then again that will hardcoded – Rajat Krishnan Apr 29 '20 at 07:04
  • It won't - you will render it in a hidden form field called `UUID` and then you can dynamically retrieve the value of that form field. – IVO GELOV Apr 29 '20 at 07:05
  • @IVO GELOV can you give me any refernce link to achieve the functionality mentioned by you? – Rajat Krishnan Apr 29 '20 at 07:29
  • If the link to the other url is present somewhere in the current page then you should get the list of all links by `document.querySelectorAll("a")` and then traverse the returned Array-like structure to find the url that you need. – IVO GELOV Apr 29 '20 at 07:33

0 Answers0