Patrioticcow
Patrioticcow

Reputation: 27058

How can I add JavaScript inside Blogger?

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.

Upvotes: 31

Views: 73533

Answers (6)

Fahim Raza
Fahim Raza

Reputation: 281

You can run this code as an external source on your blog. How? Follow the below steps:

Step 1: Store your JavaScript code in github.com, pastebin.com or any file CDN.

Step 2: Use the below piece of code to call your JavaScript code from that external source:

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

Include this code inside <head>.

Upvotes: 6

Lasantha
Lasantha

Reputation: 179

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>

Upvotes: 17

Frank Rem
Frank Rem

Reputation: 3738

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

enter image description here

Upvotes: 4

George Cummins
George Cummins

Reputation: 28936

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.

Upvotes: 20

user1392991
user1392991

Reputation: 189

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

Upvotes: 18

Gordon Seidoh Worley
Gordon Seidoh Worley

Reputation: 8088

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.

Upvotes: 2

Related Questions