I am trying to use an iframe to display another page inside my main page. The goal is to reload part of the page without reloading the whole page.
I tried using
$w(‘#html1’).src = ‘/about’;
#html1 being an HTMLElement. However I get an error saying ‘/about’ is not a url.
I tried using wix-location to build the full url, but the url returned by wix-location does not match the actual url: http://yoursitename.wixsite.com/yoursitename?dsOrigin=Editor1.4&editorSessionId=e…
I tried getting the url using document.location, but that does not seem allowed.
Is there a function to go from the page short path (like ‘/about’) to the full url? Or would it be possible to allow the .src property of HTMLElement to support short paths?
The html element won’t know what your ‘/about’ page is as it is not connected to your site structure and therefore doesn’t see the ‘/about’ as a correct url address.
It also looks like you are trying to use the full url address instead, which I would advise you to do, however it does seem to look like that you are calling your current Wix Editor url address.
You need to add the url address of the actual page exactly like it would appear when your website is live and published.
https://support.wix.com/en/article/corvid-about-the-url-structure-of-premium-and-free-sites
Oh this should be easy. Just for a moment, publish your site and visit it using your browser. Find out what is the URL of this ‘about’ page. Copy that URL and use that in your code instead of ‘/about’. You can later un-publish your site.
So if your about page’s URL is w ww.xyz123.com/about , your code would say:
$w(’ #html1 ‘).src = ’ w ww.xyz123.com/about’;
You won’t be able to see the page in preview mode though, if your site is unpublished. So to check if it is working properly, you can publish the site and check there live.
You can also find ‘about’ page’s URL using site structure bar, but publishing site and copying URL is better because you WILL need your site published if you wanna see how it looks! Hope this helps.