Header menu


Tuesday, 27 May 2014

Extract parameters from url using javascript or jquery in html file.


Parsing url in jquery or javascript to extract parameter from url in html file

If you are using a html file and you have to receive some parameters from url , then
below is the method you are looking for.

Only this you have to do ... is to call getUrlVars with field name to extract as done in this statement  :

var first_name = getUrlVars()["first_name"];  

Tuesday, 20 May 2014

In how ways you can add css to a html page ?


Methods to add css to html page :

We can add css to a page using 3 methods :

a) External css
b) Internal css 
c) Inline css 

External css : In this we make an css file and then call that file in our page using link .

Internal css : In this we write our css in head of the the html page using style tag.

Inline css : In this we add style to the element . 

The best method of adding css is external and the most powerful is inline because override    previous css included.

Thursday, 15 May 2014

Use of RedirectMatch 301 directive in htaccess.


Use of  RedirectMatch 301 directive in htaccess.

To redirect more than a single page using htaccess, you can use the "RedirectMatch 301" directive, which allows you to specify directory matching patterns using regular expressions.

Here  301 redirect is a permanent redirect method which passes between 90-99% of  ranking power to the new redirected page and (?i) signifies case insensitivity .

Point to remember:

1. (?i) starts case-insensitive mode
    (?-i) turns off case-insensitive mode

2.  /directory/cart   This is the directory which i am redirecting . When this directory structure will occur in url , page will be redirected to stated page.

3.   http://localhost/directory2?   This is my new address where i want page to be redirected.

Wednesday, 14 May 2014

Jquery not loading properly on clicking links in mobile site.


Jquery not loading properly on clicking links in mobile site.

Today while working on a mobile site , i went through a strange problem. Everything works well on site when i refresh page but when i click on links then my jquery and css are not loading properly. Resulting in improper design. After searching about the problem i came to know that on mobile jquery loads only on first page on all other pages its use preloaded js and css.

More you can read at : http://demos.jquerymobile.com/1.2.1/docs/pages/page-scripting.html

Now to solve this problem . I added rel='external'  to every link . Now whenever i click on link my jquery and css are loading properly.

Tuesday, 6 May 2014

How to get value of select box in Javascript/Jquery ?


Get value of select box in Javascript/Jquery

This is my select box.  And i want to get its value in javascript/jquery .

<select name="qt" class="qt" id='qt'>
<option value='0'>&nbsp;</option>
<option value='Newspaper'>Newspaper</option>
<option value='Facebook Ad'>Facebook Ad</option>
<option value='Google Search'>Google Search</option>
<option value='Other Internet Site'>Other Internet Site</option>
<option value='Test Prep Center'>Test Prep Center</option>

 To get its value i will use two lines.

var s = document.getElementById('qt');         /**qt is the id of select box**/
var selectval = s.options[s.selectedIndex].value; 

Working example:

Friday, 2 May 2014

PHP force file download method not working on android mobile when file path is passed from database


PHP force file download method not working on android mobile when file path is passed from database

When you use are using force download method of php to download some music/video on any android device ( I specifically performed for this ) . Then you might face two types of problems.

1.  You will get html page instead of media file.

2.  When you are passing file path from database, your file is not downloaded completely. It will show download complete after downloading some byte. In straight incomplete file is downloaded .

Below is the code that will work for solving these two problem. The points to remember are 

(a) Do not call download method from the loop where you are checking post or get request . Call download method out of GET/POST condition check loop. It is solve first problem of html pages download.

(b) Pass only file name from the database . Keep the file path static . I know this will make code hard coded but if you pass path from database then '/'  in path will create problem. And you will not be able to download file properly.

                                                I hope this will work for you too ..  :)