Thursday, May 28, 2009

Calling JavaScript Function from hyper link

While working on my project, i was thinking of a way to inform a user to click on a certain link before clicking on a particular. So, Javascript was an option to do that now the question arises

How to execute a java script function by clicking on link?



first thing i do is call the function after the href tag like
<a href="funciton_call();"> but this does not work...
first i was getting syntax error than i don't know what i did i started getting

permission denied

403 error....

then i have to call my might

Google

to rescue me out of this situation...

Google gave me couple of articles related to this issue but there is one article that explain the lots ways of achieving this or why use Javascript in this post i like to summarize article " Links & Javascript living together in harmony" by Jeff Howden.


To ways to open a link in a new window




  • <a href="#" onclick="window.open('somedoc.html', 'newWindow')" >click here</a>
    Howden J. 2002,"Links & JavaScript Living Together in Harmony",sydney,29-05-09,http://www.evolt.org/node/20938

  • calling by pseudo-protocol method

    <a href="JavaScript:window.open('somedoc.html', 'newWindow')">click here</a>
    Howden J. 2002,"Links & JavaScript Living Together in Harmony",sydney,29-05-09,http://www.evolt.org/node/20938



calling by pseudo-protocol method cause a line break if user try to open a web-page in a new window by doing shift+click .

In this article author explains the implication arises from using these methods.he said if you disable java script the first method will cause the browser to jump to the top of document and second method does nothing.

Another way to open a new window for non-Javascript user is?



<a href="somedoc.html" target="newWindow" >click here</a>

and if user want to open a pop up window, he can do this by using onclick event

<a href="somedoc.html" target="newWindow" onclick="window.open(this.href, this.target); return false"
>click here</a>
Howden J. 2002,"Links & JavaScript Living Together in Harmony",sydney,29-05-09,http://www.evolt.org/node/20938


Calling a function from a href tag for javascript compatible browser



<a
href="js_required.html" onmouseover="window.status = 'click here'; return true;"
onmouseout="window.status = '';" onclick="myFunction(); return false;"
>click here</a>

Calling a function from a href tag for non-javascript compatible browser



<a
href="js_required.html"
onmouseover="window.status = 'click here'; return true;" onmouseout="window.status = '';" onclick="return myFunction()">click here</a>
Howden J. 2002,"Links & JavaScript Living Together in Harmony",sydney,29-05-09,http://www.evolt.org/node/20938

Monday, May 18, 2009

Referential integrity constraint in MySQL

Hey guys!
This post is response to article "Using foreign keys and referential integrity in MySQL" at http://www.builderau.com.au/program/mysql/soa/Using-foreign-keys-and-referential-integrity-in-MySQL/0,339028784,339237600,00.htm

Following is a summary of how to use foreign key constraint in MySQL.

Three condition should met in accordance to use foreign key constraint among tables in MySQL:-


  • INNOBD type

    Both table should be of INNOBD type


  • Field my be indexed

    Field used in the foreign key constraint should be indexed.


  • Data type should be similar

    Data types of the field used in the foreign key relationship should be similar.



Syntax for this:-
lets assume we have two tables parent and child.

  • Creating parent table

    create table parent(id int NOT NULL Auto_Increment PRIMARY KEY,f_name varchar(15))ENGINE=INNODB;


  • Createing child table

    create table child(id int NOT NULL,l_name varchar(15))ENGINE=INNODB;

    .

  • adding foreign key constraint

    ALTER TABLE child
    ADD INDEX(id),
    FOREIGN KEY(id) REFERENCES parent(id);


    Note: we can define foreign key constraint while defining table as:

    create table child(id int NOT NULL,l_name varchar(15),INDEX(id),FOREIGN KEY(id) REFERENCES parent(id));



Significance of Foreign key Constraint!


Foreign key constraint help us in achieving Referential Integrity in MySQl. With help to reduce redundancy in database as record can be added to reference(child) table is corresponding field value exist in the refereed(parent) table.


Lets add values in to the table created above
insert into parent values (1,'John'),(2,'Peter'),(3,'William');
Now if this command is executed
insert into child values (4,'walter');
this will give an error as there is no record in parent table with field id value 4.



ON DELETE CASCADE on UPDATE CASCADE

MySQL require above keyword in foreign key constraint if user want to delete corresponding record in child table when a record in parent table is deleted.

syntax for this:

create table child(id int NOT NULL,l_name varchar(15),INDEX(id),FOREIGN KEY(id) REFERENCES parent(id) ON DELETE CASCADE ON UPDATE CASCADE);

Friday, May 15, 2009

Page rank algorithm!

Hey Guys!
this is a part of my assignment for other subject (Unix-system programing) . This article is about page rank algorithm used by goggle to find out relevance of page when the search query is process. i thought i might share it with you all as it describe the process how goggle process search query in simple language.Below is the summary of this article written by Ian Rogers, those who are interested can click on the link at the end of this post to read original article......

Ques1) what is Page Rank?


Ans 1) Page rank can be simply defined as one of the methods used by the Goggle to determine the relevance or importance of web-page and it changes whenever goggle does re-indexing. Page rank does not tell anything about content of size of page, the language or text.
whenever a search query is process by goggle, goggle looks at the url of the page displayed by browser striping off everything down the last "/", if the Toolbar PR of that parent exist goggle subtracts 1 from it and display Toolbar PR of this page. If Toolbar PR of that parent does not exist it jump to parent's parent's page and subtract 2 and so on all the way up to root of the site before displaying PR in Toolbar.


Page rank can also be define as vote of all the other pages on Internet, revealing about the importance of that page it is calculated by following formula.

  • PR(A)=(1-d)+d(PR(T1)/C(T1)+........PR(Tn)/C(Tn)


where:-


  • PR(Tn):- self importance of each page.
  • C(Tn):- vote spread by page to its outgoing links.
  • PR(Tn)/C(Tn)- if the page contains back links from page the share of vote that
    page will get is "PR(Tn)/C(Tn).
  • d - this is multiplying factor
  • 1-d - to keep sum of all pages equal to 1 this multiplying factor is introduced.



Total of 13 example are explained in this article from simple to complex in ascending order.Describing how PR in calculated in various scenario? and how can we increase the PR of the home page?


link:- http://www.ianrogers.net/google-page-rank/

Friday, May 8, 2009

How to give <TAB> in Html

Hey guys!
if you all are struggling with this question of how to give <TAB> in Html
the solution is :-
use <t> element,write your text and end with </t> it easy...

JUST KIDDING! HE. HE.



is given in web page by using non-breaking space &nbsp; character followed by the actual text. for example:

example(not follwed by &nbsp;) will look like

example

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( will shown as)

       example

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;example ( will displayed as)
                 example

so more &nbsp; more is the spacing of character/word from preceding characters/words


                                                     reference (http://webdesign.about.com/od/intermediatetutorials/qt/tiphtmltab.htm)
http://www.cookwood.com/html/extras/entities.html

Helpful tips for desgining a website


  • Points to be kept in mind while designing web page:-

    • Website should be easy to read.
    • Frames and Table should be avoided because of following reason:-

      • They slow down the uploading of web pages.

      • Web pages with frames and table receive low ranking in search engine and your work may get unnoticed.

      • CSS is much better and flexible way and frames and table are history.



  • Website should be readable.

    Short paragraphs, small text size and contrast between text color and background of web pages.Second thought should be given how web page will look like when the user print them, color choice which look good on screen may not be easy to read when printed out.


  • How the attract visitors to the website.

    • Meta tags.

      As the search engine scans the meta tags for finding searched string, so meta tags must be included in the web pages.

    • Keywords should be used for naming the web pages.

    • Lots of images and tables should be avoided as they made scanning of the web pages harder.




  • Web site address

    There are lots of places on the world wide web where web sites can be hosted for free. Web site name should be easy to understand and spell and its good if it include keywords in it.




                                                                 reference
                                 (http://nzwebs.com/webcoach.htm)