Passing parameters to a modal

I need to open one of my pages in a new window. So I’m using the modal function. Can I pass parameters to it?

Calling page:

wixWindow . openModal ( "https://my-site.com/my-page?id='"  +  user_id  +  "'" , { 
    "width" :  980 , 
    "height" :  500 
} ); 

Page opening:

let  query  =  wixLocation . query ; 
console.log( query . id ); 
); 

On the calling end I know I’m passing a parameter, but nothing is received on the other end.

Try dropping the single quotes around user_id.

Same problem.

show me the new url plus params

Calling page:

wixWindow . openModal ( “my-site.com/my-page?id=” + user_id , {
“width” : 1000 ,
“height” : 500
} )

Called page:

let query = wixLocation . query ;
console.log( query . id );
);

@internationalcovidsu you need to specify the protocol (https):

wixWindow.openModal("https://my-site.com/my-page?id="+user_id, {
        "width": 1000,
        "height": 500
    } )

@jonatandor35 Hi, yes I did specify the protocol. Sorry, I forgot to copy it when I pasted the example code here. The page opens up properly, but it’s the parameter that doesn’t pass.

@internationalcovidsu So I don’t see a reason why it shouldn’t pass. I tried it just now and it worked for me. Did you import wixLocation on the 2nd page?

Just to make sure: you are not really using " my-site.com/my-page" , right?

Yesss! I finally got it to work. Somehow the user ID was wrong. I had to tweak the query to get it right. Now it works. Can I use an anchor in the URL? Something like “https://www.my-site.com/my-page#anchor”. I’m trying it now but it’s not scrolling…