How can I add JavaScript inside Blogger?

早过忘川 提交于 2019-11-27 13:33:31

问题


I would like to add some JavaScript inside Blogger.

<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 ...

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


回答1:


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

See the Layout Guide for more details.




回答2:


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..




回答3:


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:


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.

Step 2: Use below peace of code to call your javascript code from that external source:

<script src="http://example.com/script.js"/></script>

Include this code inside <head>




回答5:


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.




回答6:


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



来源:https://stackoverflow.com/questions/6449733/how-can-i-add-javascript-inside-blogger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!