Spaces:
Running
Running
Create yt
Browse files
yt
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="ja">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>URLパラメーター版HTMLビューアー</title>
|
| 7 |
+
<style>
|
| 8 |
+
body { font-family: Arial, sans-serif; }
|
| 9 |
+
</style>
|
| 10 |
+
</head>
|
| 11 |
+
<body>
|
| 12 |
+
<h1>URLパラメーター版HTMLビューアー</h1>
|
| 13 |
+
<p>パラメーター例:?mode=html&open=about-blank&content=<h1>こんにちは</h1></p>
|
| 14 |
+
<p>パラメーター例:?mode=url&open=blob&content=https://example.com</p>
|
| 15 |
+
<script>
|
| 16 |
+
function getQueryParams() {
|
| 17 |
+
const params = new URLSearchParams(window.location.search);
|
| 18 |
+
return {
|
| 19 |
+
mode: params.get('mode'),
|
| 20 |
+
open: params.get('open'),
|
| 21 |
+
content: params.get('content')
|
| 22 |
+
};
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
function displayContent() {
|
| 26 |
+
const { mode, open, content } = getQueryParams();
|
| 27 |
+
|
| 28 |
+
if (!mode || !open || !content) {
|
| 29 |
+
document.body.innerHTML += '<p style="color: red;">パラメーターが不足しています。</p>';
|
| 30 |
+
return;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
if (mode === 'html') {
|
| 34 |
+
displayHTML(content, open);
|
| 35 |
+
} else if (mode === 'url') {
|
| 36 |
+
displayURL(content, open);
|
| 37 |
+
} else {
|
| 38 |
+
document.body.innerHTML += '<p style="color: red;">無効なモード指定です。</p>';
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
function displayHTML(html, target) {
|
| 43 |
+
if (target === 'blob') {
|
| 44 |
+
const blob = new Blob([html], { type: 'text/html' });
|
| 45 |
+
const url = URL.createObjectURL(blob);
|
| 46 |
+
window.open(url);
|
| 47 |
+
} else if (target === 'about-blank') {
|
| 48 |
+
const newWindow = window.open('about:blank');
|
| 49 |
+
if (newWindow) {
|
| 50 |
+
newWindow.document.write(html);
|
| 51 |
+
newWindow.document.close();
|
| 52 |
+
} else {
|
| 53 |
+
alert('ポップアップがブロックされている可能性があります。');
|
| 54 |
+
}
|
| 55 |
+
} else {
|
| 56 |
+
alert('無効な表示方法です。');
|
| 57 |
+
}
|
| 58 |
+
navigateToRoot();
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
function displayURL(url, target) {
|
| 62 |
+
const iframeHtml = `<!DOCTYPE html><html lang="ja"><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>iframe表示</title><style>html,body{margin:0;padding:0;overflow:hidden;width:100vw;height:100vh}</style><iframe src="${url}" style="width:100vw;height:100vh;border:none;display:block;margin:0;padding:0"></iframe></html>`;
|
| 63 |
+
|
| 64 |
+
if (target === 'blob') {
|
| 65 |
+
const blob = new Blob([iframeHtml], { type: 'text/html' });
|
| 66 |
+
const blobUrl = URL.createObjectURL(blob);
|
| 67 |
+
window.open(blobUrl);
|
| 68 |
+
} else if (target === 'about-blank') {
|
| 69 |
+
const newWindow = window.open('about:blank');
|
| 70 |
+
if (newWindow) {
|
| 71 |
+
newWindow.document.write(iframeHtml);
|
| 72 |
+
newWindow.document.close();
|
| 73 |
+
} else {
|
| 74 |
+
alert('ポップアップがブロックされている可能性があります。');
|
| 75 |
+
}
|
| 76 |
+
} else {
|
| 77 |
+
alert('無効な表示方法です。');
|
| 78 |
+
}
|
| 79 |
+
navigateToRoot();
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
function navigateToRoot() {
|
| 83 |
+
window.location.href = '/';
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
displayContent();
|
| 87 |
+
</script>
|
| 88 |
+
</body>
|
| 89 |
+
</html>
|