如何在 Blogger 中添加 JavaScript?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6449733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I add JavaScript inside Blogger?
提问by Patrioticcow
I would like to add some JavaScript inside Blogger.
我想在 Blogger 中添加一些 JavaScript。
<script type="text/javascript">
window.open("http://www.page.html", "myWindow",
"status = 1, height = 400, width = 400, resizable = 0");
</script>
If I edit the HTML and I add "
and '
they get converted to quote ...
如果我编辑 HTML 并添加"
,'
它们会被转换为quote ...
If I add an HTML/JavaScript widget the code won't run.
如果我添加一个 HTML/JavaScript 小部件,代码将不会运行。
采纳答案by George Cummins
Navigate to the Layout tab, click the "Add a Page Element" option and select the "HTML/Javascript" sub-option.
导航到布局选项卡,单击“添加页面元素”选项并选择“HTML/Javascript”子选项。
See the Layout Guidefor more details.
有关详细信息,请参阅布局指南。
回答by user1392991
Create a post. Click to enter html as opposed to compose. Type your script. To the right Click Post Settings>> Options>> Compose Modethen change Show HTML Literallyto Interpret HTML. It should now accept your script as a script intsead of text..
创建帖子。单击以输入 html 而不是撰写。键入您的脚本。在右侧单击Post Settings>> Options>> Compose Mode然后将Show HTML Literally更改为Interpret HTML。它现在应该接受您的脚本作为文本的脚本内部..
回答by Lasantha
Add your code like this:
像这样添加你的代码:
<script type='text/javascript'> //<![CDATA[ window.open("http://www.page.html", "myWindow", "status = 1, height = 400, width = 400, resizable = 0"); //]]> </script>
回答by Fahim Raza
You can run this code as an external source on your blog. How? follow below steps:
您可以将此代码作为博客上的外部源运行。如何?请按照以下步骤操作:
Step 1: Store your javascript code in github.com, pastebin.com or any file cdn.
第 1 步:将您的 javascript 代码存储在 github.com、pastebin.com 或任何文件 cdn 中。
Step 2: Use below peace of code to call your javascript code from that external source:
第 2 步:使用下面的代码从外部源调用您的 javascript 代码:
<script src="http://example.com/script.js"/></script>
Include this code inside <head>
在里面包含这个代码 <head>
回答by Frank Rem
回答by G Gordon Worley III
You should be able to add it to the page template. You can edit them from within the Blogger interface or download/edit/upload them.
您应该能够将其添加到页面模板中。您可以从 Blogger 界面中编辑它们,也可以下载/编辑/上传它们。