x

Get current page URL from designer in JavaScript

Is it possible to get the full URL of what a published page will be using JavaScript from an element dropped on that page?

Say, if I drop my element onto the page designer corresponding to page http://mysite.weebly.com/page-whatever.html. I would like to be able to extract that URL via JavaScript. There are obvious ways to do it on the published page (i.e., window.location.href), but in particular I'm trying to grab it from the designer.

Even only pulling the relative path ( /page-whatever.html ) would be quasi-satisfactory.

1,710 Views
Message 1 of 2
Report
1 REPLY 1

Hey @Brevity

You mentioned the primary means I would recommend to get the published URL for a page from within an element. ```window.location``` object.

I'm unsure what you mean when you say
> but in particular I'm trying to grab it from the designer

But, we do provide the [Page API](https://dev.weebly.com/pages-api.html) where an authenticated app is able to get details for the pages of a site. However, I am unsure if you will be able to retrieve the page data for the containing page of a specific element.

Could you describe your use-case with a little more detail please, and perhaps I can help further.

Tags (3)
1,669 Views
Message 2 of 2
Report