-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreview.html
More file actions
118 lines (108 loc) · 2.93 KB
/
Copy pathpreview.html
File metadata and controls
118 lines (108 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Website Preview</title>
<style>
body {
margin: 0;
padding: 0;
background-color: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.preview-container {
max-width: 90%;
max-height: 90vh;
box-shadow: 0 4px 20px rgba(0,0,0,0.15);
border-radius: 8px;
overflow: hidden;
background-color: white;
}
.iframe-container {
width: 100%;
height: 100%;
min-height: 80vh;
}
iframe {
width: 100%;
height: 100%;
border: none;
}
.preview-header {
padding: 15px;
background-color: #eba925;
color: white;
display: flex;
justify-content: space-between;
align-items: center;
}
.preview-title {
font-size: 16px;
margin: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 80%;
}
.close-button {
background: transparent;
border: none;
color: white;
font-size: 24px;
cursor: pointer;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
width: 30px;
height: 30px;
}
.error-message {
padding: 20px;
text-align: center;
color: #d9534f;
}
</style>
</head>
<body>
<div class="preview-container">
<div class="preview-header">
<h1 class="preview-title" id="preview-title">Website Preview</h1>
<button class="close-button" id="close-button">×</button>
</div>
<div class="iframe-container" id="iframe-container">
<!-- iframe will be inserted here -->
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const params = new URLSearchParams(window.location.search);
const url = params.get('url');
const title = params.get('title') || 'Website Preview';
document.getElementById('preview-title').textContent = title;
document.getElementById('close-button').addEventListener('click', () => {
window.close();
});
if (url) {
try {
const iframe = document.createElement('iframe');
iframe.src = url;
iframe.setAttribute('sandbox', 'allow-scripts');
iframe.setAttribute('referrerpolicy', 'no-referrer');
document.getElementById('iframe-container').appendChild(iframe);
} catch (error) {
document.getElementById('iframe-container').innerHTML =
`<div class="error-message">Error loading preview: ${error.message}</div>`;
}
} else {
document.getElementById('iframe-container').innerHTML =
'<div class="error-message">No URL provided for preview</div>';
}
});
</script>
</body>
</html>