Page Refresh in JavaScript

Refreshing a page from JavaScript is not used much but still it comes handy sometimes (like when you want to override all changes that your user has done in the page). I used to use it a few years ago when I didn’t knew anything about AJAX but now AJAX does everything. Still I thought about writing this down. Maybe it might help you (or even me in the decades to come, if ever I forget).

It is just a single line that does the job. Just type:
location.href=location.href;

You assign the window’s location to itself which forces the browser to reload the page since it observes any changes made to the URL. In a function you might implement it like:

function doSomething() {
  // do something here which would eventually
  // require a full-page refresh
  location.href=location.href;
}

Done. But note one thing, everything you write after that refreshing line won’t be executed since the control will pass to the browser to reload the page. In other words, it is like a return statement of a function.

Circular elements in CSS

Note that this technique works only on square elements. So for example you have a square selfie of yourself, say of 500px X 500px and you want to give it dashing circular look rather than that dull square photo. Here’s a quick tip for making it a perfect circle.

Continue reading

A Chrome tip for Chrome users

If you are bored with something like the below:

Bookmarks in Chrome.
Chrome bookmarks with full name

And you want something like this:

Bookmarks in Chrome.
Chrome bookmarks with just favicons

Here’s a tip for you. Just edit all the bookmarks and remove their names. That’s it.

NOTE: It doesn’t look good if you have some bookmarks that don’t have any favicons.

Resetting everything in CSS

If you are an experienced CSS styler like me, you would have sometimes notice how different web browsers apply their own styles to elements which sometimes look unappealing.

Continue reading

Returning ContentResult in ASP.NET MVC

Previously, I wrote about returning JsonResult in ASP.NET MVC. Today, I write about returning ContentResult. So, what does ContentResult actually returns? It can return any content. It can be plain text, html, xml, etc. It is specified by the MIME type in the return statement.

Continue reading

Returning JsonResult in ASP.NET MVC

Along with the ActionResult type (which is probably the most used), there is another type of return i.e. the JsonResult.

Continue reading

Developing mobile responsive sites

The use of mobiles (or smartphones) is increasing day-by-day and almost everyone today has a mobile (or a smartphone). So developing mobile responsive websites is a must.

Continue reading

JavaScript: Charms of localStorage and sessionStorage

Main Page

I recently developed a HTML5 app which was basically a totally offline sticky notes app. It could save all your sticky notes and load them even if you closed your browser and came back. It is achieved using the JavaScript local storage API.

Continue reading

Toggling visibility via CSS

Toggling elements basically means hiding them or displaying them for specific purposes. This is mostly achieved by using JavaScript or jQuery. But there is another way to do it, and that’s through CSS.

Continue reading

Hardware acceleration in CSS3

Hardware acceleration in CSS simply means using the power of the GPU to render a page. But most of the time the rendering is done by the CPU whereas only some portions are rendered by the GPU.

Continue reading