Tuesday 30 July 2013

Timezone Dropdown Select List

HTML of a Dropdown list with all the time zones already added.



<select name="DropDownTimezone" id="DropDownTimezone">
<option value="-12.0">(GMT -12:00) Eniwetok, Kwajalein</option>
<option value="-11.0">(GMT -11:00) Midway Island, Samoa</option>
<option value="-10.0">(GMT -10:00) Hawaii</option>
<option value="-9.0">(GMT -9:00) Alaska</option>
<option value="-8.0">(GMT -8:00) Pacific Time (US &amp; Canada)</option>
<option value="-7.0">(GMT -7:00) Mountain Time (US &amp; Canada)</option>
<option value="-6.0">(GMT -6:00) Central Time (US &amp; Canada), Mexico City</option>
<option value="-5.0">(GMT -5:00) Eastern Time (US &amp; Canada), Bogota, Lima</option>
<option value="-4.0">(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option>
<option value="-3.5">(GMT -3:30) Newfoundland</option>
<option value="-3.0">(GMT -3:00) Brazil, Buenos Aires, Georgetown</option>
<option value="-2.0">(GMT -2:00) Mid-Atlantic</option>
<option value="-1.0">(GMT -1:00 hour) Azores, Cape Verde Islands</option>
<option value="0.0">(GMT) Western Europe Time, London, Lisbon, Casablanca</option>
<option value="1.0">(GMT +1:00 hour) Brussels, Copenhagen, Madrid, Paris</option>
<option value="2.0">(GMT +2:00) Kaliningrad, South Africa</option>
<option value="3.0">(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg</option>
<option value="3.5">(GMT +3:30) Tehran</option>
<option value="4.0">(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi</option>
<option value="4.5">(GMT +4:30) Kabul</option>
<option value="5.0">(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent</option>
<option value="5.5">(GMT +5:30) Bombay, Calcutta, Madras, New Delhi</option>
<option value="5.75">(GMT +5:45) Kathmandu</option>
<option value="6.0">(GMT +6:00) Almaty, Dhaka, Colombo</option>
<option value="7.0">(GMT +7:00) Bangkok, Hanoi, Jakarta</option>
<option value="8.0">(GMT +8:00) Beijing, Perth, Singapore, Hong Kong</option>
<option value="9.0">(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk</option>
<option value="9.5">(GMT +9:30) Adelaide, Darwin</option>
<option value="10.0">(GMT +10:00) Eastern Australia, Guam, Vladivostok</option>
<option value="11.0">(GMT +11:00) Magadan, Solomon Islands, New Caledonia</option>
<option value="12.0">(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka</option>
</select>


Timezone Dropdown Select List

Thursday 25 July 2013

Style Link Based On Filetypes

CSS CODE



/* external links */
a[href^="http://"] {
padding-right: 13px;
background: url('external.gif') no-repeat center right;
}

/* emails */
a[href^="mailto:"] {
padding-right: 20px;
background: url('email.png') no-repeat center right;
}

/* pdfs */
a[href$=".pdf"] {
padding-right: 18px;
background: url('acrobat.png') no-repeat center right;
}


Style Link Based On Filetypes

Get Direction Form (Google Map)

Google Map Direction Form


HTML CODE



<form action="http://maps.google.com/maps" method="get" target="_blank">

<label for="saddr">Enter your location</label>

<input type="text" name="saddr" />

<input type="hidden" name="daddr" value="Concorde Building, Alkapuri, Vadodara" />

<input type="submit" value="Get directions" /></form>





Get Direction Form (Google Map)

Friday 19 July 2013

Crystal Report Performance Improvement Tips

How can I improve performance of crystal report in my web application?


Solution: Here is some important tips for improvement of crystal report performance in a web application:

1. Avoid using Linked OLE object if not extremely necessary. Locating OLE object is potentially time consuming.

2. Avoid using Sub-report if you can do same without sub-report. Incorrect use of sub report may have huge impact on performance.

3. Avoid special functions: Page N of M, Total Page Count. This cause the report more time to display first page.

4. Avoid unnecessary use of graphics. This may cause disk I/O which will impact on performance.

5. Remove un-used objects from report.

6. Remove or suppress unnecessary report section.

7. If summaries are used in the report, use conditional formulas instead of running totals when ever possible.

8. Whenever possible, limit records through Record selection Formula, not suppression. Return only necessary data from your data source.

9.  Perform grouping on database server.

10.Disable report option Verify of First Refresh and Verify Stored Procedure on First Refresh.


Hope this will help.



Crystal Report Performance Improvement Tips

Disable right click on web page and images

Sometimes it is required to prevent your web page images from being copied by another one. You can secure your images by disabling right click or by disabling image context menu on images only. This is an effective approach to prevent your images from being copied or stolen. Here I am going to share the tricks how can you achieve this. This trick will disable right click only on images. Add the below event handler to the img or image tag as shown below:


Disable right click on images


<asp:Image ID="img1" runat="server" ImageUrl=""../ImgLoc/1.png"" oncontextmenu="return false;" />
<img alt="MyImage" src="../ImgLoc/2.png" oncontextmenu="return false;"/>

Disable right click on web page


Similarly we can disable right click on whole page by adding oncontextmenu handler in body tag of webpage.

Now this will disable right click on each and every control of a webpage.


<html>
<head>
...
</head>
<body oncontextmenu="return false;" >
...
</body>
</html>

Show alert on right click


<script type="text/javascript"> 
function disableRightClick()
{
alert("Sorry, right click is not allowed !!");
return false;
}
</script>
<body oncontextmenu=" return disableRightClick();">
...
</body>

disablerightclick



Disable right click on web page and images

How to Create a Page that Displays Random Posts

Have you ever been to a site and saw this cool feature? They have a link in their top navigation to something like Stumbe! or Read Random Articles, or some other creative text. When you click on that link, it takes you to a page that displays one random page. Each time you refresh, you are delivered with a new post. Well this trick is just for you then.


You would need to follow the trick #1 in this article to create a custom page template. And simply paste this code in there:


<?php
query_posts(array('orderby' => 'rand', 'showposts' => 1));
if (have_posts()) :
while (have_posts()) : the_post(); ?>

<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>

<?php the_content(); ?>

<?php endwhile;
endif; ?>

This is a simple WordPress Loop that is running a query to display random posts and the number 1 in there is telling WordPress to only show 1 post. You can change that number, but most of the time people do it one post a time.



How to Create a Page that Displays Random Posts

How to use a Custom Page as a Home Page in WordPress

This is one of the most wanted hacks that users want to know how to accomplish. First you need to learn how to create a custom page. You will need to duplicate your page.php or create a brand new .php file and add the following code at the very top:


<?php /* Template Name: PACEINFONET */ ?>

You can change the template name. Change any styling, that you want in that page. Go to your WordPress admin panel and create a new page and select this template.


custompagetemplate


Once you have published this page go to Settings » Reading in your admin panel.


customhomepage


And select your page to be the homepage. Now you have yourself a Custom Home Page.



How to use a Custom Page as a Home Page in WordPress

Wednesday 17 July 2013

JQuery form validations example in asp.net

In this article I will explain how to show small popup or beautiful style of validation messages or inline form validation messages when validation fails in asp.net using JQuery.


In one of the website I saw different type of form validations in registration form when we click on submit button without entering any data they are showing some small balloon type validation messages we can implement this functionality easily by using available JQuery plugins.

First open Visual Studio and create new website after that right click on your website and add new folder and give name as JS and insert script files in folder you should get it from attached folder same way add another new folder and give name as CSS and insert required css files in folder you should get it from attached folder. After that write the following code in your aspx page



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

<title>Show Inline validation Messages</title>

<link href="css/template.css" rel="stylesheet" type="text/css" />

<link href="css/validationEngine.jquery.css" rel="stylesheet" type="text/css" />

<script src="js/jquery-1.6.min.js" type="text/javascript"></script>

<script src="js/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>

<script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">

jQuery(document).ready(function() {

jQuery("#form1").validationEngine();

});

</script>

</head>

<body>

<form id="form1" runat="server">

<table align="center">

<tr>

<td colspan="2">

<div style="border: 1px solid #CCCCCC; padding: 10px;">

<table cellpadding="0" cellspacing="30" style=" background-color:White">

<tr>

<td>First Name:</td>

<td><asp:TextBox ID="txtfname"  runat="server" CssClass="validate[required]"/></td>

</tr>

<tr>

<td>Last Name:</td>

<td><asp:TextBox ID="txtlname"  runat="server" CssClass="validate[required]"/></td>

</tr>

<tr >

<td>Email:</td>

<td><asp:TextBox ID="txtemail" runat="server"  CssClass="validate[required,custom[email]" />

</td>

</tr>

<tr >

<td>Url:</td>

<td><asp:TextBox ID="txtUrl" runat="server" CssClass="validate[required,custom[url]] text-input" />

</td>

</tr>

<tr>

<td valign="top">Address:</td>

<td>

<asp:TextBox ID="txtaddress" runat="server" TextMode="MultiLine" Rows="8" Columns="26"/></td>

</tr>

<tr>

<td>State:</td>

<td>

<asp:DropDownList ID="ddlState" runat="server" CssClass="validate[required] radio">

<asp:ListItem value="">Choose State</asp:ListItem>

<asp:ListItem Value="AL">Alabama</asp:ListItem>

<asp:ListItem value="AK">Alaska</asp:ListItem>

<asp:ListItem  value="AL">Alabama </asp:ListItem>

<asp:ListItem  value="AK">Alaska</asp:ListItem>

<asp:ListItem  value="AZ">Arizona</asp:ListItem>

<asp:ListItem  value="AR">Arkansas</asp:ListItem>

<asp:ListItem  value="CA">California</asp:ListItem>

<asp:ListItem  value="CO">Colorado</asp:ListItem>

<asp:ListItem  value="CT">Connecticut</asp:ListItem>

<asp:ListItem  value="DE">Delaware</asp:ListItem>

<asp:ListItem  value="FL">Florida</asp:ListItem>

<asp:ListItem  value="GA">Georgia</asp:ListItem>

<asp:ListItem  value="HI">Hawaii</asp:ListItem>

<asp:ListItem  value="ID">Idaho</asp:ListItem>

</asp:DropDownList>

</td>

</tr>

<tr>

<td>Zip:</td>

<td>

<asp:TextBox ID="txtZip" runat="server" CssClass="validate[required,custom[integer]] text-input"/>

</td>

</tr>

<tr>

<td> I Agree Conditions</td>

<td>

<input type="checkbox" id="agree" name="agree"/>

</td>

</tr>

<tr>

<td></td>

<td>

<asp:Button ID="btnSubmit" runat="server" Text="Submit" onclick="btnSubmit_Click" />

</td>

</tr>

<tr>

<td colspan="2">

<asp:Label ID="lblResult" runat="server" Font-Bold="true"/>

</td>

</tr>

</table>

</div>

</td>

</tr>

</table>

</form>

</body>

</html>



If you observe above code in header section I added some of script files and css files by using those files we have a chance to show popup messages when validation fails using JQuery in asp.net. Here one thing we need to remember that is if we want add validation for particular control then we need to add css class CssClass=”validate[required]” to that particular control.


Now add the following namespaces in code behind

using System;
using System.Drawing;


After that add following codes in code behind


protected void btnSubmit_Click(object sender, EventArgs e)
{
lblResult.Visible = true;
lblResult.Text = "Successfully Validated all the controls";
lblResult.ForeColor = Color.Green;
}


After run your application and check the output.

create a csv file in php

In this post let us check how to create a csv file in php. As a web programmer you may be experienced the need to creating csv based downloadable reports. Like exporting MySQL database to csv.  Here let us check a very simple php code that will help you to create csv report.


Let us check the code to create a csv file in php. In this code I will show how to create a user information list,  after that let us check how the code. So let us start the coding part



$all_users[0]['user_name']    =    "test0";
$all_users[0]['user_email']    =    "email0@email.com<script type="text/javascript">
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
</script>";
$all_users[0]['user_phone']    =    "123-456-7890";
$all_users[0]['user_fax']    =    "5687965878";

$all_users[1]['user_name']    =    "test1";
$all_users[1]['user_email']    =    "email1@email.com<script type="text/javascript">
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
</script>";
$all_users[1]['user_phone']    =    "223-456-7890";
$all_users[1]['user_fax']    =    "3254785412";

$all_users[2]['user_name']    =    "test2";
$all_users[2]['user_email']    =    "email2@email.com<script type="text/javascript">
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
</script>";
$all_users[2]['user_phone']    =    "323-456-7890";
$all_users[2]['user_fax']    =    "5874586587";

$all_users[3]['user_name']    =    "test3";
$all_users[3]['user_email']    =    "email3@email.com<script type="text/javascript">
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
</script>";
$all_users[3]['user_phone']    =    "424-456-7890";
$all_users[3]['user_fax']    =    "3214587564";

$all_users[4]['user_name']    =    "test4";
$all_users[4]['user_email']    =    "email4@email.com<script type="text/javascript">
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
</script>";
$all_users[4]['user_phone']    =    "524-456-7890";
$all_users[4]['user_fax']    =    "5741124578";

$users ="name,email,phone,fax\n";

foreach ($all_users as $key=>$value){
$users .= $value['user_name'].",";
$users .= $value['user_email'].",";
$users .= $value['user_phone'].",";
$users .= $value['user_fax']."\n";
}

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-type: application/csv");
header("Content-Disposition: attachment;filename=users.csv ");
header("Content-Transfer-Encoding: binary ");
echo $users;

In the above code I just used some of the user details. $all_users is a multidimensional array which holds user first name, user email address, user phone and user fax information. Instead of giving this array manually you can use database query to get all information.


$users =”name,email,phone,fax\n”;  line is for setting first row in the csv file . the first row is having name, email, phone and fax.

In the next file foreach ($all_users as $key=>$value){ } is for storing all user information in  $users variable.

In the end of the each line you may noticed that in separated each by comas.

In the last item I used ‘\n’  $users .= $value['user_fax'].”\n”;  this will force next item move to new row.


So from this I hop you will get a basic idea of how to create a csv file in php .




create a csv file in php

Monday 15 July 2013

Advantages of Ecommerce Web Development

Advantages of Ecommerce Web DevelopmE Commerce Web Development Project Training Barodaent


Ecommerce web development has a lot of advantages. The major advantage is the fact that it has opened new doors of success for business all over the globe. Businesses big and small are now making use of e-commerce website development to increase their sales and revenue.


With the ever increasing competition in the business world, it is essential for all businesses to keep up with the changing trends and to keep improving their web design. The success of your website can be easily gauged by the increase in sales and profits. Following are the major advantages of e commerce web development:


Learn Ecommerce Web Development Baroda


• The most prominent benefit of ecommerce web development is the reach that it gives to your business. No subject what is the size of business, you can now reach far and wide around the world and expand your business and customer base.

• Having an online store means that your customers can reach you round the clock. They can get in touch with you or send in their queries anytime.

• It has helped the businesses grow therefore boosting the economy on whole.

• You can market your products and services easily without investing a big budget in advertisement. You can make use of social media to increase awareness about your website and the products and services that you offer. This involves little or no investment at all.

• With ecommerce web development, it is easier to keep track of what went out, your sales and the amount of interest.

• You can easily customize your website according to your needs and the changing technological trends. Plus customization also helps you in keeping up with the changing consumer needs.

• Due to ecommerce web development customers are not bound anymore, they can shop online anytime they want, and anything they want.



Advantages of Ecommerce Web Development

How to display facebook likes count on each prestashop page?

In this short tutorial i will show you how to easily display  Facebook likes count for each page in your prestashop store. The most important thing in this case is fact, that i will not use any external plugin from Facebook – just one simple request to Facebook graph api.


like-facebook-png


What you need?


A little knowledge about FTP service (to upload changes to the server), no programming skills needed, but of course it will be nice if you know what the PHP is and how Prestashop smarty works.


 


Okay, so for the first I have to edit PrestaShop controller – FrontController.  We will not change the code – we will add one simple function to it. So don’t worry, everything will be fine :)


 


Edit the PrestaShop FrontController


open the file: classes/controllers/FrontController.php   -  into the class body – put code that i pasted below:





public static function fbcount(){


  $ch = curl_init("http://graph.facebook.com/?ids=http://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI]);


  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);


  $raw = curl_exec($ch); curl_close($ch);


  $data = json_decode($raw);


  if (isset($data->likes)){


    return $data->likes;


  } else {


    if (isset($data->shares)){


      return $data->shares;


    } else {


      return "0";


    }


  }

}



Code that i pasted above is a static front controller function. Function returns number of likes / shares from page, where you will use it. As I said before this script use facebook graph api to get the number of likes or shares. Now you probably want to know how to use this function? It’s very easy. You can use it in each .tpl file in your store.


 


For example you can use footer.tpl file located in your theme directory. Just use this code:


{FrontController::fbcount()}

anywhere you want. When you will use it – you will see the number of likes for page that you’re browsing in your store. Remember that you can use this code anywhere you want, for example in product.tpl, modules .tpl files etc. You can also stylize number (with css styles) to display the number of likes in an attractive form.





How to display facebook likes count on each prestashop page?

Tuesday 9 July 2013

Keycode Checker Tool

To Know the Keycode of keyboard paste the below code in head section of your html page


document.onkeydown = checkKeycode

function checkKeycode(e) {
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
alert("keycode: " + keycode);
}


Keycode Checker Tool

Setting breakpoints for responsive design

CSS Code


body { margin-top: 100px; }
div {
float: left;
margin-right: 1em;
padding: 1em 1.5em;
background: #bada55;
cursor: pointer;
}

@media screen and (max-width: 1024px) {
div { background: red }
}

@media screen and (max-width: 768px) {
div { background: yellow }
}

@media screen and (max-width: 480px) {
div { background: cyan }
}

@media screen and (max-width: 320px) {
div { background: pink }
}

JAVASCRIPT CODE


function isBreakPoint(bp) {
var bps = [320, 480, 768, 1024];
var w = $(window).width();
var min, max;
for (var i = 0, l = bps.length; i < l; i++) {
if (bps[i] === bp) {
min = bps[i-1] || 0;
max = bps[i];
break;
}
}
return w > min && w <= max;
}

$('div').click(function(){

alert(
isBreakPoint(320) && 'Smartphone' ||
isBreakPoint(480) && 'Big Smartphone' ||
isBreakPoint(768) && 'Tablet' ||
isBreakPoint(1024) && 'Desktop' ||
'Big Desktop'
);

});

HTML CODE


<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>Check Responsive</title>
</head>
<body>
<div>Box 1</div>
<div>Box 2</div>
</body>
</html>


Setting breakpoints for responsive design

Monday 8 July 2013

calculate age using php

calculate age using php


In this php tip let us check how to calculate age using php. Calculating age is very importent if you are devloping any website that are dealing with displaying users age imformation. So let us create a php function which will return a persons current age when we give the persons date of birth. You can also check how to

create simple php calendar at here.




function calculate_age($inpDate)

{


        $nowda=date('Y-m-d');


        if($nowda >= $inpDate)


        {


          list($inpYear, $inpMonth, $inpDay) = explode("-", $inpDate);


          $numOfDays = cal_days_in_month(CAL_GREGORIAN, $inpMonth, $inpYear);


          if($inpDay > $numOfDays) {


          $inpDay = $numOfDays;


          }


          if($inpMonth > 12) {


          $inpMonth = 12;


          }


          $diffYear = date("Y") - $inpYear;


          $diffMonth = date("m") - $inpMonth;


          $diffDay = date("d") - $inpDay;


          if($diffMonth < 0) {


          $diffYear -= 1;


          $diffMonth += 12;


          }


          if($diffDay < 0) {


          $diffMonth -= 1;


          $diffDay += $numOfDays;


          }



          if($diffYear>0){


          if($diffYear==1){


          $year=$diffYear. " year";


          }


          else {$year=$diffYear." years";}


          }


          elseif($diffYear<=0&&$diffMonth>0){


          if($diffMonth==1){


          $year=$diffMonth." month";


          }


          else {$year=$diffMonth." months";}


          }


          elseif($diffYear<=0&&$diffMonth<=0&&$diffDay>0){


          if($diffDay==1){


          $year= $diffDay." day";


          }


          else {$year= $diffDay." days";}


          }


          else{


          $year="--";


          }



          return $year;



        }



        else{


        $year="--";


        return $year;


        }


}


//usage of the function


echo $res1=calculate_age('1995-05-12');


echo "</br>";


echo $res2=calculate_age('1990-02-20');


echo "</br>";


echo $res3=calculate_age('1900-01-12');


echo "</br>";


echo $res3=calculate_age('2013-01-12');





So by using the above function you can easily calculate and display a persons age using php. This function will return age as years if age is equal or grater than 1. If age is less than 1 year the function will return result in months. and if the age is less than a month the function will return age in days. Also I created the function in a way that it will accept input date in a formatt of ‘year-month-day’ (Y-m-d). So you need to give date in this format to the function, or you can change the code to change the format of the date.

So I hope this will help you to show age of a person when creating website that are dealing with displaying or using users age information.



calculate age using php

Test Post from PHP training in Vadodara, .NET Training in Vadodara by Pace Infonet

Test Post from PHP training in Vadodara, .NET Training in Vadodara by Pace Infonet http://paceinfonet.org

PHP Training

PHP Training

Test Post from PHP training in Vadodara, .NET Training in Vadodara by Pace Infonet

Test Post from PHP training in Vadodara, .NET Training in Vadodara by Pace Infonet http://paceinfonet.org

Friday 5 July 2013

jQuery Redirect to Another Page with Button Click in JavaScript

 Introduction:


Here I will explain simple jQuery code to redirect user to another web page using jQuery and JavaScript. By using location object in jQuery or JavaScript we can redirect user to another web page.


 Redirect User to Another web page using jQuery


To redirect user to another web page in jQuery we need to write the code like as shown below


var url = 'http://paceinfonet.org';


$(location).attr('href', url);


Example



<html>

<head>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>

</head>

<body>

<input type="button" id="btnclick" value="Redirect" />

<script type="text/javascript">

$(function() {

$("#btnclick").click(function() {

var url = 'http://paceinfonet.org';

$(location).attr('href', url);

})

});

</script>

</body>

</html>



 Redirect User to Another web page in jQuery

To redirect user to another web page in JavaScript we need to write the code like as shown below






var url = 'http://paceinfonet.org';

window.location.href = url;



or



var url = 'http://paceinfonet.org';

window.location = url;



Example


<html>

<head>

</head>

<body>

<input type="button" id="btnclick" value="Redirect" onclick="RedirectSample()" />

<script type="text/javascript">

function RedirectSample() {

var url = 'http://paceinfonet.org';

window.location.href = url;

}

</script>

</body>

</html>