Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/JotFormReact.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const JotFormEmbed = ({
...rest
}) => {
const iframeRef = React.useRef();
const [iframeSrc, setIframeSrc] = React.useState(formURL);
const [componentStyles, setComponentStyles] = React.useState({
height: initialHeight,
overflow: 'hidden',
Expand Down Expand Up @@ -61,6 +62,17 @@ const JotFormEmbed = ({
}
};

const iframeURL = new URL(formURL);
const iframeParams = new URLSearchParams(iframeURL.searchParams);
const urlParams = new URLSearchParams(window.location.search);
const searchParams = new URLSearchParams({
...Object.fromEntries(urlParams),
...Object.fromEntries(iframeParams),
})
searchParams.set('isIframeEmbed', '1');
iframeURL.search = searchParams.toString();
setIframeSrc(iframeURL.toString());

if (window.addEventListener) {
window.addEventListener('message', handleMessages, true); // Capture
} else if (window.attachEvent) {
Expand All @@ -76,7 +88,7 @@ const JotFormEmbed = ({
return (
<iframe
ref={iframeRef}
src={formURL}
src={iframeSrc}
title="JotForm Form"
style={{
...componentStyles,
Expand Down