# wixLocation.path (Specific Page)

**URL:** <https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [January 15, 2018, 4:09am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928 "2018-01-15T04:09:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [January 15, 2018, 4:09am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/1 "2018-01-15T04:09:07Z")

</div>

Hi

I have this code so far, but I doesn’t seem to be working.

I’m wanting a lightbox to load every time it lands on a certain page of my site (my forum home page, not the others / sub pages of the forum).

```javascript
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

$w.onReady(function () {
	if (wixLocation.path == 'forum') {
		wixWindow.openLightbox('Main Menu');
	}
}); 

```

> Is there a way of launching a lightbox on a specific page only not on all sub categories of the forum?

e.g only on 2 pages:

1. [www.example.com/forum/](http://www.example.com/forum/)

2. [www.example.com](http://www.example.com)

I was thinking of using wix-storage (local) to get round the issue but this doesn’t really fix the route of the problem.

Many thanks for any help

Thomas

---

<div class="post-metadata">

**Author:** ![roi-bendet](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roi-bendet/32/1283_2.png) [@roi-bendet](https://forum.wixstudio.com/u/roi-bendet)\
**Post date:** [January 15, 2018, 12:01pm UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/2 "2018-01-15T12:01:51Z")

</div>

Hi Thomas,  
What do you receive in console.log(wixLocation.path) before the if condition ?  
Roi

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [January 15, 2018, 12:32pm UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/3 "2018-01-15T12:32:03Z")

</div>

Hi Roi,

I’m fairly new at this coding malarky, unfortunately. Where would I find this?

The site is called:

It might give you an idea of what i’m trying to achieve with the lightbox

Best

Thomas

---

<div class="post-metadata">

**Author:** ![roi-bendet](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roi-bendet/32/1283_2.png) [@roi-bendet](https://forum.wixstudio.com/u/roi-bendet)\
**Post date:** [January 15, 2018, 1:12pm UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/4 "2018-01-15T13:12:56Z")

</div>

Hi,  
Your logic is correct.  
If (wixLocation.path == ‘forum’) could never be truthy becouse wixLocation.path is Array type and ‘forum’ is string type (unless the length is empty ‘’ == []). It can be truthy if you replace wixLocation.path with wixLocation.path[the position of the correct string in the array].  
If forum is the home page of your site wixLocation.path would be equals to [“”]

Roi

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [January 16, 2018, 9:22am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/5 "2018-01-16T09:22:54Z")

</div>

Hi Roi

I’ve tried three other options and nothing seems to be working;

any more ideas? I’ve tried these variations

```javascript
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

$w.onReady(function () {
	if (wixLocation.path == '') {
		wixWindow.openLightbox('Main Menu');
	}
}); 

```

```javascript
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

$w.onReady(function () {
	if (wixLocation.path == "") {
		wixWindow.openLightbox('Main Menu');
	}
}); 

```

---

<div class="post-metadata">

**Author:** ![roi-bendet](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roi-bendet/32/1283_2.png) [@roi-bendet](https://forum.wixstudio.com/u/roi-bendet)\
**Post date:** [January 16, 2018, 9:50am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/6 "2018-01-16T09:50:23Z")

</div>

Try this:

```javascript
$w.onReady(function () { 
    if (wixLocation.path[0] == "") { 		
        wixWindow.openLightbox('Main Menu'); 
        } 
}); 

```

Let me know if if works  
Roi

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [January 16, 2018, 11:00am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/7 "2018-01-16T11:00:23Z")

</div>

Hi Roi

It loads on the opening screen (when I first load the site) but doesn’t load again while navigating around and then back home.

Also, it still loads when entering the site via a Facebook link to a sub category post.

Best

Thomas

---

<div class="post-metadata">

**Author:** ![roi-bendet](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roi-bendet/32/1283_2.png) [@roi-bendet](https://forum.wixstudio.com/u/roi-bendet)\
**Post date:** [January 16, 2018, 4:23pm UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/8 "2018-01-16T16:23:29Z")

</div>

This one works for me:  
if (wixLocation.path.length === 0)  
Roi

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [January 17, 2018, 5:16am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/9 "2018-01-17T05:16:19Z")

</div>

Hi Roi

I’ve tried using this version and now the lightbox isn’t showing at all. I’m not sure where I’m going wrong if it’s working for you?

```javascript
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

$w.onReady(function () { 
    if (wixLocation.path.length === 0) { 		
        wixWindow.openLightbox('Main Menu'); 
        } 
});

```

Thomas

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [January 17, 2018, 6:38am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/10 "2018-01-17T06:38:56Z")

</div>

Alternatively I’ve tried running it via an Input Box and using said box as a validator to open/trigger the lightbox

Would something like this (or a variation of) work?:

```javascript

import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

let url = wixLocation.url;

$w.onReady(function () {
$w("#input1").value = url; 
	if (input1 === "https://www.example.com") {
		wixWindow.openLightbox('Main Menu');
	}
});

```

---

<div class="post-metadata">

**Author:** ![roi-bendet](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roi-bendet/32/1283_2.png) [@roi-bendet](https://forum.wixstudio.com/u/roi-bendet)\
**Post date:** [January 17, 2018, 9:01am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/11 "2018-01-17T09:01:50Z")

</div>

Hi,  
That wont work.  
You didn’t created the variable “input1”

```javascript
import wixLocation from 'wix-location'; 
import wixWindow from 'wix-window'; 
  
$w.onReady(function () { 
    let url = wixLocation.url;
    if (url === "https://www.packerpal.com") { 		
        wixWindow.openLightbox('Main Menu'); 
        } 
});

```

This one works for me  
Roi

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [January 18, 2018, 2:38am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/12 "2018-01-18T02:38:05Z")

</div>

Hi Roi

I’ve managed to get it working. But when I’m on the site, if I navigate to a category and then back to the home page, it doesn’t trigger the lightbox again. I physically have to reload the site in order to get the lightbox to popup again.

Is there any way to make it pop up everytime they navigate (within the site) back to the home page?

Also, it’s still popping up when I enter the site to a sub page / different page to the home screen?

Best

Thomas

---

<div class="post-metadata">

**Author:** ![roi-bendet](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roi-bendet/32/1283_2.png) [@roi-bendet](https://forum.wixstudio.com/u/roi-bendet)\
**Post date:** [January 18, 2018, 9:43am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/13 "2018-01-18T09:43:48Z")

</div>

Hi,  
Have you tried my example ?  
Roi

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [January 18, 2018, 9:55am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/14 "2018-01-18T09:55:45Z")

</div>

Hi Roi

This is using the code provided in your last example. It keeps opening on all screens regardless of landing page.

Also, it doesn’t re-load once while navigating the site?

Best

Thomas

---

<div class="post-metadata">

**Author:** ![roi-bendet](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roi-bendet/32/1283_2.png) [@roi-bendet](https://forum.wixstudio.com/u/roi-bendet)\
**Post date:** [January 18, 2018, 10:06am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/15 "2018-01-18T10:06:06Z")

</div>

Hi,  
Can you please share a link to you site ?  
Roi

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [January 18, 2018, 10:20am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/16 "2018-01-18T10:20:09Z")

</div>

The site’s called:

Sorry, it’s loading when I click back. But also loading on sub linked pages too and auto redirecting to home.

Many thanks

Thomas

---

<div class="post-metadata">

**Author:** ![roi-bendet](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roi-bendet/32/1283_2.png) [@roi-bendet](https://forum.wixstudio.com/u/roi-bendet)\
**Post date:** [January 18, 2018, 10:38am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/17 "2018-01-18T10:38:58Z")

</div>

The lightbox opens only on entry screen.  
Can you video capture the unwanted scenario  
You can use this tool: [www.screencast.com](http://www.screencast.com)  
Roi

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [January 18, 2018, 10:55am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/18 "2018-01-18T10:55:52Z")

</div>

Hi Roi

Here is an example of when I use a link from facebook to one of the posts. Would be great if we could PM the ‘back of house / working examples’ so people can’t see my pre-site workings! (don’t mind the code bit, helps everyone along) (although I’ve read a fair few people mention that, so i’ll leave it alone!)

Here is an example of when I use a link from facebook to one of the posts. Would be great if we could PM the ‘back of house / working examples’ so people can’t see my pre-site workings! (don’t mind the code bit, helps everyone along) (although I’ve read a fair few people mention that, so i’ll leave it

Many thanks!

Thomas

---

<div class="post-metadata">

**Author:** ![thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@thomas](https://forum.wixstudio.com/u/thomas)\
**Post date:** [January 23, 2018, 1:22am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/19 "2018-01-23T01:22:11Z")

</div>

Hi Roi

I’ve submitted a video as requested of the issue. I don’t suppose you have managed to further take a look at this have you?

Many thanks

Thomas

---

<div class="post-metadata">

**Author:** ![roi-bendet](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roi-bendet/32/1283_2.png) [@roi-bendet](https://forum.wixstudio.com/u/roi-bendet)\
**Post date:** [January 23, 2018, 10:25am UTC](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928/20 "2018-01-23T10:25:43Z")

</div>

Hi Thomas,  
I Did, this is an issue that we are working on. it may take some time to fixed.  
Roi

[Next page](https://forum.wixstudio.com/t/wixlocation-path-specific-page/26928.md?page=2)
