Skip to main content

Posts

Showing posts with the label Javascript Resuable functions

Date comparison custom functions in JS - Function to check the given date is not greater than current date - Also checks the date is a valid date

Here are some JS custom date comparison functions that may be useful to you. First one checks the validity of date and compares with current date. Javascript function to check whether a given date is greater than current date and also checks whether the date is a valid one. Here is a simple JS function which takes the text-box Id as input, then checks whether the given date is a valid date and then compare the date value with the current date and alerts if the entered date is greater that current date . Here the function expects the input date in dd/mm/yyyy format.

JS function to check whether the given string contains only Alphanumeric characters - Javascript String functions

Javascript ( JS ) function to check whether the given string contains only Alphanumeric characters. Simple JS function to check whether the string contains either only Numbers, Capital or Small Letter alphabets or a combination of all.

How to create simple lightbox like div popups to show images or contact form using CSS and Javascript?

Light weight and Simple lightbox with CSS and Javascript Create a Lightbox Effect with CSS and little bit of JavaScript Div Popups are usually used on web pages to display enlarged Images or data capturing forms like contact or feedback. Instead of showing the data on a new window popup, we can use DIV element to display the same with out loading on a separate popup.

Google Transliterate API - Simple Online editor in Javascript to type in your own language

Javascript based simple Online editor to type in your own language Google Transliterate API Integration It's great to type contents to your website in your own language. Google provides a simple Javascript based Language editor, which can be implemented on your website.The name of the API is Google Transliterate API . The code is simple and very easy to understand and integrate. Here you have to define a pair of languages, ie, a Source language and a Destination language. The content you type on editor using the source language is converted to the destination language. While type user will be provided options to choose exact word.

Javascript JS function to break a URL into its components or parts

How to break or split a given URL into various parts like Host, protocol, relative path, end file , directories etc? A simple JS function is given below which uses window.location object to retrive parts of a url into an array.

Facebook Share button for Sharing Your Web contents - How to create and add FB share Button to websites?

Share your web contents with FB share button INSTRUCTIONS FOR CREATING FACEBOOK SHARE BUTTON AND IT'S INTEGRATION TO WEBSITE FB Share button is one of the quickest way's for people to share contents online. It allows facebook users to share a web content to Facebook, share with particular friends or with a group. Alternatively, they can share in a private message. On clicking the button, it will ask to login. if you are logged in it will load a popup form with data to be shared once submitted, data will be shared to user friend list and time line.

Facebook Like button for popularise Your Web contents - How to create and integrate FB Like Button to websites?

Popularise Your web contents with FB Like button INSTRUCTIONS FOR CREATING FACEBOOK LIKE BUTTON AND IT'S INTEGRATION TO WEBSITE FB Like button is the quickest way for people to share content with their friends. It allows FB users to share pages and content from your site back to their Facebook profile with one click, so all their friends can read them. On clicking the button, it will ask to login. if you are logged in it will ask to confim and finally asks to add comment.

Twitter Share / Tweet button for better content sharing - Instructions for adding Tweet button to your website

The Tweet Button or Twitter Share button is a small widget from twitter API service which allows users to easily share a website with their followers. How it works When a user clicks the Tweet Button he is asked to login to Twitter. If the user is new to Twitter there will be option to create a twitter account. After successful login a "Share Box" appears which is already completed with required data to share. The user can alter the content if they need.If everything fine, then user Tweets (posts) it. The shared contents will be posted to Twitter pages of all followers. How to integrate Twitter Share button Integration of a Tweet button to your website is very simple. You can alter the appearance of the tweet button based on the attributes that you add on the button code

Javascript (JS) function to strip HTML tags in a string - PHP strip_tags function equivalent in JS

PHP strip_tags() function equivalent in Javascript Strip_tags function in php removes all html tags except the allowed tags from a given string. I did some Online search and could find a coupleof functions that were able to do this task. Here are few  JS functions that does Strip_tags function Here's the strip_tags() with allowable tags

Javascript (JS) function to validate Email Address

Email Validator Script in JS Here is a simple function in Javascript (JS) which uses regular expression to tests whether the given string matches to a valid email patters. The JS built-in function used here is test() . Use the function given below to validate Email address

JS Date Time functions - How to get Current Day, Month, Year and time using Javascript?

How to get Current Day, Month, Year and time using Javascript? There are several Date and time functions in JS to retrive current Date, Day name, Month name, year and Time Javascript has a special class called Date, this Date class is initiated by creating a Date object and using several functions in the Date class we can access segments of Current Date and time How to create a Date object: // declare date object var today = new Date(); Date and Time function in JS: //get current day today.getUTCDay() // current month today.getUTCMonth() // get current year today.getFullYear() //get Hour of the day today.getHours(); //get minute of the day today.getMinutes(); //get second today.getSeconds(); Here is a simple illustration of above mentioned functions <script> function getDateTime() { var daysOfWeek = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "S...

Online HTML escape tool

Online tool for HML escaping, this tool replaces all occurences of < , > , ', " with corresponding html equivalents. This tool is helpful for escaping javascript codes which are to be embeded in blogger templates. Just input your JS script or any string and get the HTML escaped output string.

How to loop through the items in a select box using Javascript?

Looping through the items in a select box using JS Use the code given below to parse through the options in a select box and alert the Text and Value of each options. you can alter the function as per your need. sample code is given below: <form> <select id="test" name="test"> <option value="First Value" >First Text</option> <option value="Second Value" >Second Text</option> <option value="Third Value" >Third Text</option> <option value="Fourth Value" >Fourth Text</option> <option value="Fifth Value" >Fifth Text</option> </select> <input type="button" value="Check" onclick="loopSelectBox('test')" > </form> <script> function loopSelectBox(selectBoxId){ var obj=document.getElementById(selectBoxId); for(i=0; i < obj.options.length ;i++){ alert("Value :...

How to get the Query string of a URL using the Javascript (JS)?

JS function get the Query string of a URL or value of each parameter using the Javascript(JS)? If you want to get your current page's url var my_url=document.location; to get the query string part of the url use like this: var my_qry_str= location.search; this will return the part of the url starting from "?" following by query string Lets assume that your current page url is http://www.crozoom.com/2013/page.html?qry1=A&qry2=B then the location.search function will return " ?qry1=A&qry2=B " to exclue "?", do like this:

How to get the location part of an absolute url using Javascript?

Let's discuss this with an example: A url is having 3 parts which will be separated by a slash " / ": 1. protocol 2. Domain / host name 3. location sample url : http://www.crozoom.com/2013/googlenotes/techiscripts The above give sample url is splitted to following parts: protocol : http:// Domain : www.crozoom.com Location : /2013/googlenotes/techiscripts Now the question is how to do it using the JS code in simple steps: 1. remove the protocol part from the string 2. find first occurence of "/" 3. Add 1 to the first occurence position that we get in the above step 4. get the substring of the absolute url starting from the position given from the above step till the end of the string the above steps are implemented in simple JS code snippet <script> function getUrl(absolute_url) { var pagelink=""; //var myurl=document.URL; var myurl=absolute_url; myurl=myurl.replace("http://",""); m...

How to add BlogIt button or Widget on your blogger website

STEPS FOR ADDING BLOG IT BUTTON ON YOUR BLOGS BlogIt button is a wonderful option for sharing your Blog pages with other blogger users. Blog It button allows other blogger users to post the Your Blog post's link on their blogger website. How it works: A blogger user who is browsing your website, Clicks on the BlogIt button or link A popup blogger editor appears with your blog post title and a Link to your post When user submit the data after selecting apporpriate blog, Then the content will be posted to that blog. The code for doing this is given below <script> function load_blogit_form(){ Q=''; x=document; y=window; if(x.selection) { Q=x.selection.createRange().text; } else if(y.getSelection) { Q=y.getSelection(); } else if(x.getSelection) { Q=x.getSelection(); } window.open('http://blogger.com/blog_this.pyra?t='+escape(Q)+'&u='+escape(location.href)+'&n='+escape(document.title),'bloggerForm',...

How to display French Accented characters in Javascript alert box?

Solution for displaying French Accented Characters in JS alert box or Confirm dialog box Suppose you have a french string like "Prénom du membre" and you want to display this using a Javascript alert / Confirm Dialog box like: alert("Prénom du membre"); confirm("Prénom du membre"); the alert message may look like "Prénom du membre". Ie, the display will have some un-recogonized characters. You might have tried using the html equivalents of french characters. In the above case like this: alert("Pr&eacute;nom du membre"); confirm("Pr&eacute;nom du membre"); here the alert message may look like "Prénom du membre". to fix this you have to use the unicode escape sequence of such characters, like the one given below: Solution: alert("Pr \u00E9 nom du membre"); confirm("Pr \u00E9 nom du membre"); 00E9 is unicode escape sequence for  é. for more unicode equivalen...

Google PlusOne (g +1) Button Code - How to add Google PlusOne (g +1) Button on web pages?

Google PlusOne (g +1) Button Code - Instructions to add Google PlusOne (g +1) Button on web pages Sharing Your website content through Google search is now simple and easy Google PlusOne (g +1) Button You can add google +1 button to allow Your website visitors to recommend Your web contents to google search as well as to share it on the google Plus pages. By adding the +1 button to your website, you allow your users to recommend your content to their circles and drive traffic to your site.

How to read RSS feed using Javascript and Diplay it on Web page?

Use the following script to read and display the RSS feed content on your web-page using Javascript <script language="JavaScript" src="http://feed2js.org//feed2js.php?src=YOU_RSS_FEED_URL&chan=y&date=y&utf=y&html=a" charset="UTF-8" type="text/javascript"></script> <noscript> <a href="http://feed2js.org//feed2js.php?src=YOU_RSS_FEED_URL&chan=y&date=y&utf=y&html=y">View RSS feed</a> </noscript> > Substitute  YOUR_RSS_FEED_URL    with the Source URL of your rss feed There is a  tool that will help you to format a feed's display with the information you want to use on your web site. All you need to enter is the URL for the RSS source, and select the desired options . Read More about RSS Feed reader using JSfrom following site: http://feed2js.org/index.php?s=build

Simple Slider show using Javascript - JS Slide show script

Simple Slider show using Javascript The following script will populate the slider container control with the contents in the slider content js array in regular interval of time. Here You can pause the slider on mouse over and later resume the slider on mouseout events. Sample Javascript code is given below: Save the following script as  slider.js //--------- CODE STARTS ------- var mbSlider=new Array(); arrSlide[0]= 'HTML Content in Slide1'; arrSlide[1]= 'HTML Content in Slide2'; var slide_count=arrSlide.length; var slide_ind=0; var slide_speed=5000; var slide_int; //function to fill slide content to the slider ctrl function displaySlide( ){  if( slide_ind == slide_count || slide_ind < 0 )   slide_ind=0; document.getElementById('slide_contents').innerHTML=arrSlide[slide_ind]; slide_ind ++; } //function to pause slide show function pauseSlide(){ clearInterval(slide_int); } //function to continue slide show function runSl...


Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »
Member
Search This Blog