如何在Blogger中添加JavaScript?

[英]How can I add JavaScript inside Blogger?


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並添加“和”它們會轉換為引用...

If I add an HTML/JavaScript widget the code won't run.

如果我添加HTML / JavaScript小部件,代碼將無法運行。

6 个解决方案

#1


17  

Navigate to the Layout tab, click the "Add a Page Element" option and select the "HTML/Javascript" sub-option.

導航到布局選項卡,單擊“添加頁面元素”選項,然后選擇“HTML / Javascript”子選項。

See the Layout Guide for more details.

有關詳細信息,請參閱布局指南。

#2


14  

Create a post. Click to enter html as opposed to compose. Type your script. To the right Click Post Settings >> Options >> Compose Mode then change Show HTML Literally to Interpret HTML. It should now accept your script as a script intsead of text..

創建一個帖子。單擊以輸入html而不是撰寫。輸入你的腳本。在右側單擊“發布設置”>>“選項”>>“撰寫模式”,然后將“顯示HTML字面”更改為“解釋HTML”。它現在應該接受您的腳本作為腳本intsead文本..

#3


11  

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>

#4


3  

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>

在中包含此代碼

#5


2  

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界面中編輯它們,也可以下載/編輯/上傳它們。

#6


1  

Select Template. And click 'Edit HTML'. Now you can add your script.

選擇模板。然后點擊“修改HTML”。現在您可以添加腳本了。

enter image description here


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2011/06/23/7129fe59a1e6df12991a2d4eee3aac09.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com