I have built a dashboard in Javascript/React/node.js to sit within a shopify store owners admin page.
Each store owner will have their own data and dashboard, I am trying to get the shop name in the dashboard.
The dashboard is an iFrame of my dashboard that I am hosting.
I have tried many many methods of trying to get the parent page's URL and data such as below:
None of them work they all return undefined or say 'localhost' is there anyway to capture this with Javascript?
Alternatively I have noticed when the authentication process begins when the user installs the app the domain is collected and stored, is there a way to capture this each time the store-owner is using the app? So I can try this from the server -> dashboard rather than dashboard -> server?
There is a method of using sessions with cookies but if someone clears their cookies I think the app would need to be reinstalled.
any help would be massively appreciated.
var url = (window.location != window.parent.location)
? document.referrer
: document.location.href;
parent.document.location
parent.window.document.location
parent.window.location
parent.document.location.href
Hi,
I would definetely not recommend using frontend JavaScript for this. Generally, any kind of cross iframe communication not originating from the same source will end up in tears unless you're creating bookmarklet type apps though even those are fragile.
That's what the API's are for and with your app being installed by a merchant in their store, they grant you API access to query their store - among which is also store meta data such as the name.
Hope this helps!
same kind i have tried out and this worked for me :
User | Count |
---|---|
14 | |
12 | |
10 | |
8 | |
7 |