Add test iframe
This commit is contained in:
224
templates/test_iframe.html
Normal file
224
templates/test_iframe.html
Normal file
@@ -0,0 +1,224 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Iframe Test - Quote Upload</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background: #f5f5f5;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.test-container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #333;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.test-info {
|
||||
background: #e3f2fd;
|
||||
border-left: 4px solid #2196f3;
|
||||
padding: 15px;
|
||||
margin-bottom: 20px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.test-info p {
|
||||
margin: 5px 0;
|
||||
color: #1976d2;
|
||||
}
|
||||
|
||||
.iframe-wrapper {
|
||||
background: white;
|
||||
border: 2px solid #ddd;
|
||||
border-radius: 8px;
|
||||
padding: 10px;
|
||||
margin-bottom: 30px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.iframe-wrapper h2 {
|
||||
margin-bottom: 10px;
|
||||
color: #555;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.iframe-container {
|
||||
width: 100%;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
background: white;
|
||||
}
|
||||
|
||||
iframe {
|
||||
width: 100%;
|
||||
border: none;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.size-controls {
|
||||
margin-top: 10px;
|
||||
padding: 10px;
|
||||
background: #f9f9f9;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.size-controls label {
|
||||
margin-right: 15px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.size-controls input[type="number"] {
|
||||
width: 80px;
|
||||
padding: 5px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.size-presets {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.size-presets button {
|
||||
padding: 5px 15px;
|
||||
margin-right: 10px;
|
||||
background: #2196f3;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.size-presets button:hover {
|
||||
background: #1976d2;
|
||||
}
|
||||
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mobile {
|
||||
max-width: 375px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.tablet {
|
||||
max-width: 768px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.desktop {
|
||||
max-width: 1024px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="test-container">
|
||||
<h1>Iframe Embedding Test</h1>
|
||||
<div class="test-info">
|
||||
<p><strong>Purpose:</strong> Test how the quote upload page appears when embedded in an iframe</p>
|
||||
<p><strong>URL:</strong> <span id="iframeUrl"></span></p>
|
||||
</div>
|
||||
|
||||
<div class="iframe-wrapper">
|
||||
<h2>Responsive Iframe (Auto Height)</h2>
|
||||
<div class="iframe-container" id="iframeContainer">
|
||||
<iframe id="testIframe" src="/" title="Quote Upload Test"></iframe>
|
||||
</div>
|
||||
<div class="size-controls">
|
||||
<label>Width: <input type="number" id="widthInput" value="100" min="300" max="2000"> px</label>
|
||||
<label>Height: <input type="number" id="heightInput" value="800" min="400" max="3000"> px</label>
|
||||
<div class="size-presets">
|
||||
<button onclick="setSize('mobile')">Mobile (375px)</button>
|
||||
<button onclick="setSize('tablet')">Tablet (768px)</button>
|
||||
<button onclick="setSize('desktop')">Desktop (1024px)</button>
|
||||
<button onclick="setSize('full')">Full Width</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Display the iframe URL
|
||||
document.getElementById('iframeUrl').textContent = window.location.origin + '/';
|
||||
|
||||
const iframe = document.getElementById('testIframe');
|
||||
const iframeContainer = document.getElementById('iframeContainer');
|
||||
const widthInput = document.getElementById('widthInput');
|
||||
const heightInput = document.getElementById('heightInput');
|
||||
|
||||
// Listen for height messages from the iframe
|
||||
window.addEventListener('message', function (event) {
|
||||
if (event.data && event.data.type === 'sedutto-ifr-height') {
|
||||
iframe.style.height = event.data.height + 'px';
|
||||
heightInput.value = event.data.height;
|
||||
}
|
||||
});
|
||||
|
||||
// Update iframe size when inputs change
|
||||
widthInput.addEventListener('input', function () {
|
||||
iframeContainer.style.width = this.value + 'px';
|
||||
});
|
||||
|
||||
heightInput.addEventListener('input', function () {
|
||||
iframe.style.height = this.value + 'px';
|
||||
});
|
||||
|
||||
// Size presets
|
||||
function setSize(preset) {
|
||||
const sizes = {
|
||||
mobile: 375,
|
||||
tablet: 768,
|
||||
desktop: 1024,
|
||||
full: '100%'
|
||||
};
|
||||
|
||||
if (preset === 'full') {
|
||||
iframeContainer.style.width = '100%';
|
||||
iframeContainer.classList.remove('mobile', 'tablet', 'desktop');
|
||||
widthInput.value = window.innerWidth - 60; // Account for padding
|
||||
} else {
|
||||
const width = sizes[preset];
|
||||
iframeContainer.style.width = width + 'px';
|
||||
iframeContainer.className = 'iframe-container ' + preset;
|
||||
widthInput.value = width;
|
||||
}
|
||||
}
|
||||
|
||||
// Initial auto-height setup
|
||||
iframe.addEventListener('load', function () {
|
||||
// Try to get initial height
|
||||
setTimeout(() => {
|
||||
try {
|
||||
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
|
||||
const height = iframeDoc.documentElement.scrollHeight;
|
||||
iframe.style.height = height + 'px';
|
||||
heightInput.value = height;
|
||||
} catch (e) {
|
||||
// Cross-origin restrictions - rely on postMessage
|
||||
console.log('Cannot access iframe content directly, using postMessage');
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user