我一直在一个名为 data:text/html 的链接上编码,(如果你把它写在地址栏中,你可以在后面写任何 html 和 css。)有谁知道如何缩短这个链接,我试过 goo .gl 和位,但它说它无法创建链接。这是我的代码:
data:text/html, <!DOCTYPE html> <html lang="en-us"> <head> <title>Griffin Inc</title> <link rel="icon" href="https://docs.google.com/a/my.rbusd.org/drawings/d/1RbhLPr2Jq2WL-NCKn0lMKVkM3fPw-ZRUdFTurpLHkBk/pub?w=960&h=720"> <link href="https://preview.c9users.io/check222/new-tab/style.css" rel="stylesheet"> <script src="https://preview.c9users.io/check222/new-tab/main.js"></script> </head> <body id="body"> <marquee loop="-1" scrollamount="7" width="100%" id="google-search-engine-marquee"> <strong>Search Griffin Inc</strong> </marquee> <form action="https://www.google.com/search" method="get"> <input type="search" name="q" placeholder="Google" title="Search" id="search-bar"> <input type="submit" value="Search" id="search-button"> </form><p style="color: black">Color Picker:<input id="color_picker" type="color" onchange="showHex();"><p style="color: black">Type notes here: </p> <textarea id="notes"></textarea> <p></p> <button id="Google-Docs" class="pageContent" onclick="window.open('https://docs.google.com/document/u/0/?tgif=d')">Google Docs</button> <button id="Google-Drive" class="pageContent" onclick="window.open('https://drive.google.com/drive/my-drive')">Google Drive</button> <button id="Google-Slides" class="pageContent" onclick="window.open('https://docs.google.com/presentation/u/0/?tgif=d')">Google Slides</button> <button id="Google-Drawings" class="pageContent" onclick="window.open('https://docs.google.com/drawings/d/1YTlXmt29AVduvI2OnSfYYMKw1IrcB3LPFPBh6g1p6TI/edit')">Google Drawings</button> <iframe src="http://schneider7.weebly.com/homework--due-dates" width="100%" height="1000"/> </body> </html>
最佳答案
Is it possible to shorten a data:text/html, link?
当然可以——如果您可以创建一个重定向到所述数据 URI 的短 URL。正如您所观察到的,许多流行的服务不支持数据 URI。但是,没有什么能阻止您进行自己的重定向。
缩短数据 URI 有用吗?我想不出这样做有任何合理的用例。 data:text/html URI 用于非常小的演示(按两位或三位字节计数的顺序 - 这里是 couple 的 examples )和快速实验。头脑正常的人不会将整个 HTML 文档放在数据 URI 中,并期望最终用户像使用真实文档一样使用它。至关重要的是,数据 URI 不能被搜索引擎编入索引,尽管当然这取决于用例,这可能是有利的也可能是不利的。
此外,Internet Explorer and Microsoft Edge don't support navigating to data URIs of any kind for security reasons ,所以即使您可以创建一个重定向到数据 URI 的短 URL,它也不会在任何地方都有效。
如果您想要链接到可运行/可编辑网页片段的“短 URL”,有大量专门为此目的而设计的服务,例如 JSFiddle , JS Bin , CodePen ... list 还在继续。这些都生成具有相当短标识符的 URL。此外,它们都是基于 HTTP 的,因此它们适用于 IE 和 Microsoft Edge。
关于html - 是否可以缩短数据 :text/html, 链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44463539/