How do we get the current page id in site code , and based off that do something to a text box.
For example
if($w(“#pageHome”).IsVisible){
$w(“#txtBox”).text = “Welcome”;
}
Thanks!
Hi asegal,
Actually you’re very close.
Just use:
$w("#pageHome").id
See here documentation.
Liran.
Thanks Liran,
I guess, I made it sound confusing. I need to know what page I am on. I know there’s pageHome and pageAbout, for instance – I need to know what page I am on and do things accordingly.
And since we’re on the subject why IsVisible is not even recognized in the code editor in my example as a valid member?
Thanks in advance,
Oh, sorry
So in this case, use wixLocation.path .
The first index (index 0) should be the one that you’re looking for.
Regarding the other question:
Each code is running in a context of a page, so isVisible is meaning less for a page, as it is always visible (isVisible is used for elements that you can hide/collapse).
Liran.