Hello there!
Does anyone of you know how to get the link (website address) of the current page?
Hi! Thanks for the link, but unfortunately, I don’t know why it didn’t work. I used this code, but it gets a wrong url prefix.
$w("#element").text = wixSite.currentPage.url;
and also this one…
$w("#element").text = wixSite.currentPage.prefix;
but this one only gets the text which I colored blue, not the orange one.
https://www.example.com/forum/6f78c488-f7b1-404b-aeeb-ea4e0541cfd6
Is there anyway I could get the orange text above using .prefix?
@aeroengineerz7 Try putting the code inside the page onReady since that API is not completely ready to use until the page fully loads.
import wixSite from 'wix-site';
$w.onReady(function () {
let current = wixSite.currentPage;
console.log("http://website.org" + current.url);
});
@tony-brunsman I already did!
import wixSite from 'wix-site';
$w.onReady(function () {
let current = wixSite.currentPage;
$w("#ownerID").text = "http://www.example.com" + current.url;
console.log("http://www.example.com" + current.url);
});
This url is showing
http://www.example.com/member-id
instead of this one.
http://www.example.com/forum/6f78c488-f7b1-404b-aeeb-ea4e0541cfd6
You can use the wix-location API to retrieve varous URL variations of your site. The url() function will return the “full” URL of the current page. One of the other functions might suit your needs better.
Thank you very much @yisrael-wix ! It works!
@yael-luria
Where did you find, that it is not supported anymore?
@yael-luria It is fully supported and works fine. No installation is needed. You just need to import . See the the wix-location API documentation.
@yisrael-wix Okay, thanks