Short a string without cutting words

I develop this function to short the string without cutting the words. As we now that PHP’s substr() function only provide the part of the string, substr() function provide the string between the two parameters, start from and end to.

So I need a function that provide the string arround the given starting from and end to range. Below given function provide the arround complete word from the string. This function check the nearest space into the string and provide the nearest word without cutting. If you guys have a better alternative then please feel free to share the codes in the comment section.

Read More

Countdown timer in javascript

Here i introduce with the simple countdown timer script written in JavaScript. My main purpose behind this countdown timer script is just logout the user if he/she is idle. In this example i set the idle time 15 minutes, means the user will automatically logout if he/she do not active on the page. To achieve this i used window.setInterval() javascript function, which is call my own defined function after every 1 second. As you see in the below example i have created a function getIdleTime(), this function calculate every minute and second and display to the user, as you see i called an id with document.getElementById(), just call the id where you want to show your countdown timer.

Read More

Speed Up your website with htaccess caching

If we are talking about SEO, then google has been announced that the speed of your web page also matter to improving your page rank and website performance. In this post we are talking about that how to improve the website loading performance so that the speed of loading the webpage also increase, and if you want to check the increased speed of your webpage the there is a page speed add-on available for Firefox, which is automatically integrated in firebug.

All this can happen with a single “.htaccess” file, which means htpertext access(htaccess). htaccess is just a simple but most powerful ASCII file. You can create this file with any editor.

Read More

Fade In / Fade Out with CSS Transition

It is easy to make fade in / fade out effect with pure CSS, means no need to any JavaScript or jQuery. But this fade in/out effect only working in latest browsers only, here is the list of the supported WebKit browsers:

Browsers list:

  1. Chrome 1.0
  2. Firefox(Gecko) 4.0(2)
  3. Internet Explorer 10
  4. Opera 10.5
  5. Safari (WebKit) 3.2

To make it all browser compatible you have to use jQuery or JavaScript, in jQuery it is simple with the fadein() and fadeout() function. There are few transition property that we are using in this fade in / out effect.

Read More

Keyboard key codes detect with JQuery

JavaScript is one of the best Server Scripting Language for client side programming and JQuery is one of its library. JQuery is widely used by designers because it’s providing a lot of functionality just with few easy steps well I am not talking here about the designing part; we are talking about the keyboard key detection.

JavaScript Methods to Detect Keyboard keys:

There are three methods to detect the key codes of keyboard.

  1. keyup
  2. keydown
  3. keypress

If we are talking about the cross-browser compatible then keyup and keydown are the best solution for this.

Read More

Access Cross Domain feeds with PHP

Now easy to access and display cross domain feeds with php. With the use of DOMDocument() class we can easy access the feeds. In this given example I have fetched only the title and the link from the feeds. First of all start with the path from where you want to access the feeds, make sure that your path will be full with the complete URL, like I have mentioned on the given example. Then simply access the Tag of that feed/xml file with the member function getElementsByTagName(), and follow the code :

Read More