how to transfer a url from page A to page B?

hello
I store the url (https://www.wix.com) in page A
And i go to page 2

import wixLocation from "wix-location";
import {session} from 'wix-storage';
 
export function Submit_click(event) {
session.setItem('website', “https://www.wix.com”);  
wixLocation.to("/page2");
});

In page 2
I want to assign the url to an html box

import {session} from 'wix-storage';
 
$w.onReady(function () {  
const websiteurl = session.getItem(website);
$w('#html1').src = websiteurl;   
});

But it does not work
Thanks for your help

How to solve the Problem by your own?

At first look, your code seems to be right. You store the url in wix-storage on page-A and get the data back out of wix-storage in page-b.

What you are not doing is, to use the console, to log every single step of your code for debugging purposes.
Already worked with the console?

$w . onReady ( function (){ const websiteurl = session . getItem ( website console.log("URL: ", websiteurl) ;
});

What do you get as RESULT in your CONSOLE? Is it the expected result?

If YES, and it does still not work, try to add a URL to your HTML-Component → MANUALY.
Does it work after adding the URL manualy?
If it does still not work, take a look onto the corresponding VELO-API for more i iormation.

Thank you for your answer
I am indeed trying to solve the problem by doing research on the net and it is very enriching.

I read the console when it does not work and there it says to me:
Wix code SDK error: The url parameter that is passed to the src method cannot be set to the value . It must be of type url.

I deduced that websiturl is a string and I have to convert this string to url

If YES, and it does still not work, try to add a URL to your HTML-Component → MANUALY.


i did it and it works
the reason for this search is that I have multiple identical pages in which I just change the link of the html box, the idea is to make a single page the different urls sent from the previous page

@ludovicvialla This is what is important for you…

Thank you for your help but I don’t understand what you’re trying to make me understand

my current code is the same as the one you copied in your message
and it works well :

$w('#html1').src = “https://www.wix.com”;   

if i use wix-storage to store “https://www.wix.com”, it no longer works

Already tried…

let url = new URL(string);
...or...
let uri = new URI(string);

after an hour of misunderstanding, here is the problem solved
(‘website’) and not (website)

session.getItem('website');

@ludovicvialla
Yes, right.
But in this case you did not use the console-log the right way, shown in already mentioned example…

$w . onReady ( function (){ const websiteurl = session . getItem ( website console.log("URL: ", websiteurl) ;
});
Doing it this way, you normaly should get something like → UNDEFINED because the variable → website never existed and normaly should be a key for wix-storage.

Try to use more the console.
Also you have had the ability to check for output-type…
console.log(typeof websiteurl)

Never forget–> console=your best friend!:wink::v:

Thank you for your advice

@ludovicvialla
No problem✌