Tuesday, September 15, 2009

JavaScript in Blog Post






Today, I was going through one blog and it was written that JavaScripts works in a post, only when we put all the scripts in a single line. It also says that if there will be a line break, JavaScript won't work.

I found it is not correct. So thought to publish this post with example.
It works straight away. Just click on the button, which is on top of this post. It really works!

It is very simple to use JavaScript in a blogpost. If you want to check it, here are the steps:-

Step1:- Go to New Post. Click on Edit HTML tab. (Don't click on Compose).

Step2:- Paste following code there and simply, publish the post.

<script type="text/javascript">
function show_alert()
{
alert("JavaScript in Posting... it works!");
}
</script>
<input value="JavaScript in Blog Post - Click me."onclick="show_alert()" size="477" style="height: 30px; width: 358px;" type="button" />

It started working now. Go to you blog and you can verify it.
Isn't it very simple to use JavaScript?

I used JavaScript to create a Cookie. It is kept at my testing blog. In my testing blog, if you search in Right-SideBar, you will find a Button named "Remember Name". Click on that button. Enter your name in the next box. And click "Remember Name" button, again. It will remember your name.

Now, return to that blog after an hour or so and check if the button still remembers your name?
It will, unless you have not deleted cookies manually.

One last JavaScript trick!!



Blue Ocean


For Further Reading,
JavaScript

0 comments:

Post a Comment

 

Popular Posts

Popular Posts On EAB

Demo Donation
This demonstration will accept a fixed amount of $0.05.

Man Behind This Blog

My Blogs