Zoho Trusted Partner in Digital Transformation
Your iframe structure is fundamentally correct! Here's what you're doing right and areas for optimization:
<div class="vce-zoho-form-container">
<div class="loading-overlay" id="formLoader">
<div class="loading-spinner"></div>
<div class="loading-message">Loading Email Form...</div>
</div>
<iframe name="Email_ZCRM_Frame"
id="zcrm-form-iframe"
src="https://creatorapp.zohopublic.com/yourpage/yourform/form-perma/Email_ZCRM/D0NZ3z6ykWzEEXZ7xkwwEagkSPZbyourownkey8d7a21hqYWY9uKgyhOttVMeUgS2qfnsUOpO3dKG4CkHubnEuvDxsnO3D?DealID=<%=input.DealID%>"
style="width: 100%; border: none; transition: opacity 0.3s ease;"
frameborder="0"
scrolling="yes"
loading="lazy"
onload="hideLoader()"
onerror="showError()">
</iframe>
<div class="error-message" id="errorMessage" style="display: none;">
<p>Unable to load form. <a href="#" onclick="reloadForm()">Try again</a></p>
</div>
</div>
.vce-zoho-form-container {
position: relative;
width: 100%;
max-width: 1200px;
margin: 0 auto;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
overflow: hidden;
}
#zcrm-form-iframe {
width: 100%;
min-height: 600px;
height: 80vh;
max-height: 1000px;
opacity: 0;
transition: opacity 0.3s ease;
}
#zcrm-form-iframe.loaded {
opacity: 1;
}
.loading-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255,255,255,0.95);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 10;
}
.loading-spinner {
width: 40px;
height: 40px;
border: 4px solid #f3f3f3;
border-top: 4px solid #E53E3E;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 15px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loading-message {
color: #666;
font-size: 16px;
font-weight: 500;
}
.error-message {
padding: 20px;
background-color: #ffebee;
color: #c62828;
text-align: center;
border-radius: 4px;
margin: 10px;
}
/* Mobile Responsive */
@media (max-width: 768px) {
.vce-zoho-form-container {
margin: 10px;
border-radius: 4px;
}
#zcrm-form-iframe {
min-height: 500px;
height: 70vh;
}
.loading-message {
font-size: 14px;
}
}
@media (max-width: 480px) {
#zcrm-form-iframe {
min-height: 400px;
height: 60vh;
}
}
function hideLoader() {
const loader = document.getElementById('formLoader');
const iframe = document.getElementById('zcrm-form-iframe');
if (loader) {
loader.style.display = 'none';
}
if (iframe) {
iframe.classList.add('loaded');
}
}
function showError() {
const loader = document.getElementById('formLoader');
const errorMsg = document.getElementById('errorMessage');
if (loader) {
loader.style.display = 'none';
}
if (errorMsg) {
errorMsg.style.display = 'block';
}
}
function reloadForm() {
const iframe = document.getElementById('zcrm-form-iframe');
const loader = document.getElementById('formLoader');
const errorMsg = document.getElementById('errorMessage');
if (errorMsg) {
errorMsg.style.display = 'none';
}
if (loader) {
loader.style.display = 'flex';
}
if (iframe) {
iframe.classList.remove('loaded');
iframe.src = iframe.src; // Reload iframe
}
}
// Auto-resize iframe based on content (if same-origin)
function autoResizeIframe() {
const iframe = document.getElementById('zcrm-form-iframe');
try {
if (iframe.contentDocument) {
const height = iframe.contentDocument.body.scrollHeight;
iframe.style.height = height + 'px';
}
} catch (e) {
// Cross-origin restriction - use fixed height
console.log('Auto-resize not available due to cross-origin restrictions');
}
}
// Timeout fallback
setTimeout(function() {
const loader = document.getElementById('formLoader');
if (loader && loader.style.display !== 'none') {
showError();
}
}, 15000); // 15 second timeout
// In your Deluge script - validate and sanitize parameters
dealID = input.DealID;
// Validate DealID exists and is numeric
if (dealID == null || dealID == "" || !dealID.isNumber()) {
dealID = "0"; // Default value or redirect to error page
}
// URL encode for safety
encodedDealID = encodeUrl(dealID);
// Build secure iframe URL
iframeURL = "https://creatorapp.zohopublic.com/yourpage/yourform/form-perma/Email_ZCRM/D0NZ3z6ykWzEEXZ7xkwwEagkSPZbfXYOURKEY8d7a21hqYWY9uKgyhOttVMeUgS2qfnsUOpO3dKG4CkHubnEuvDxsnO3D?DealID=" + encodedDealID;
<iframe name="Email_ZCRM_Frame"
id="zcrm-form-iframe"
src="<%=iframeURL%>"
sandbox="allow-forms allow-scripts allow-same-origin allow-popups"
referrerpolicy="strict-origin-when-cross-origin"
loading="lazy">
</iframe>
<div class="mobile-fallback" style="display: none;">
<p>Having trouble with the form? <a href="<%=iframeURL%>" target="_blank" class="btn-primary">Open in New Window</a></p>
</div>
<script>
// Show fallback on mobile if iframe fails
if (/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
setTimeout(function() {
if (!document.getElementById('zcrm-form-iframe').classList.contains('loaded')) {
document.querySelector('.mobile-fallback').style.display = 'block';
}
}, 10000);
}
</script>
<link rel="preconnect" href="https://creatorapp.zohopublic.com">
<link rel="dns-prefetch" href="https://creatorapp.zohopublic.com">
// Advanced lazy loading with Intersection Observer
const iframeObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const iframe = entry.target;
if (iframe.dataset.src) {
iframe.src = iframe.dataset.src;
iframe.removeAttribute('data-src');
iframeObserver.unobserve(iframe);
}
}
});
});
// Use data-src instead of src for lazy loading
// <iframe data-src="your-url" ...>
// PostMessage communication for height adjustment
window.addEventListener('message', function(event) {
if (event.origin === 'https://creatorapp.zohopublic.com') {
if (event.data.type === 'resize') {
const iframe = document.getElementById('zcrm-form-iframe');
iframe.style.height = event.data.height + 'px';
}
}
});
// Listen for form submission completion
window.addEventListener('message', function(event) {
if (event.origin === 'https://creatorapp.zohopublic.com') {
if (event.data.type === 'formSubmitted') {
// Handle successful submission
showSuccessMessage();
// Optional: redirect or update parent page
}
}
});
Ready to enhance your Zoho Creator applications? When you're ready to implement these optimizations and explore advanced form capabilities, you can access Zoho Creator's full platform at https://zurl.co/tNScV, where you'll find comprehensive form-building tools, advanced iframe options, and responsive design features.
creatorscripts@zoho.com | 8444552263
⭐ Proud Winner of Zoho Creator's Tech Star in Healthcare ⭐
Trusted by Businesses Worldwide
This email was sent automatically with Creator Scripts
© 2025 Creator Scripts - Zoho Trusted Partner in Digital Transformation