I’m new to Wix and having trouble with dynamically setting the src of an iframe I have in a custom HTML block.
I want to set the src to a page on one of our domains and pass on the querystring from the calling page.
When loading the page, the console shows the captured value so I know that bit is working.
However, the iframe does not load the requested page. The code I have seems like it should work - the function does run - but doesn’t do what I expect it to.
I’ve been searching around as much as I can but cannot find a working solution.
What am I missing?
Or am I going about this the wrong way?
Thanks for any help.
Neil.
I have added a custom code block with :
<iframe id="galleryframe" width="100%" height="100%" src="">
In Dev mode, I have added this code:
import wixLocation from “wix-location” ;
$w.onReady (() => {
const id = wixLocation.query;
console.log(id);
$w(“#galleryframe”).src=“https://mysite.com/mypage.php?”+id;
});
HTML block - styling removes the scrollbars from the final page. Wix puts an html element inside an iframe so this stops it showing the scrollbars:
Create a standard HTML page, add