الخميس، 4 ديسمبر 2014


1) What is a data integrity?

A. It is the data contained in database that is non redundant.

B. It is the data contained in database that is accurate and consistent.

C. It is the data contained in database that is secured.

D. It is the data contained in database that is shared.


2) As per equivalence rules for query transformation, selection operation distributes over

A. Union

B. Intersection

C. Set difference

D. All of the above


3) In SQL the word 'natural' can be used with

A. inner join

B. full outer join

C. right outer join

D. all of the above


4) Which of the following relational algebraic operations is not from set theory?

A. Union

B. Intersection

C. Cartesian Product

D. Select


5) An entity set that does not have sufficient attributes to form a primary key is a

A. strong entity set

B. weak entity set

C. simple entity set

D. primary entity set


6) In case of entity integrity, the primary key may be

A. not Null

B. Null

C. both Null and not Null

D. any value


7) A logical schema

A. is the entire database.

B. is a standard way of organizing information into accessible parts.

C. describes how data is actually stored on disk

D. both A and C


8) Which of the operations constitute a basic set of operations for manipulating relational data?

A. Predicate calculus

B. Relational calculus

C. Relational algebra

D. None of the above


9) Which of the following is another name for weak entity?

A. Child

B. Owner

C. Dominant

D. All of the above


10) Which of the following is record based logical model?

A. Network Model

B. Object oriented model

C. E-R model

D. None of the above



11) A file manipulation command that extracts some of the records from a file is called

A. SELECT

B. PROJECT

C. JOIN

D. PRODUCT


12) In E-R Diagram derived attribute are represented by

A. Ellipse

B. Dashed ellipse

C. Rectangle

D. Triangle


13) The natural join is equal to

A. Cartesian Product

B. Combination of Union and Cartesian product

C. Combination of selection and Cartesian product

D. Combination of projection and Cartesian product


14) In E-R diagram relationship type is represented by

A. Ellipse

B. Dashed ellipse

C. Rectangle

D. Diamond


15) In E-R diagram generalization is represented by

A. Ellipse

B. Dashed ellipse

C. Rectangle

D. Triangle


16) A table joined with itself is called

A. Join

B. Self Join

C. Outer Join

D. Equi Join


17) ........... means multiple copies of the same data items.

A. Data reduction

B. Data integrity

C. Data consistency

D. Data redundancy


18) Different values for the same data item is referred to as .......

A. data consistency

B. data inconsistency

C. data integrity

D. data duplication


19) The .......... returns row after combining two tables based on common values.

A. difference

B. product

C. join

D. union


20) The .......... can be used to ensure database integrity.

A. entity integrity

B. database constraints

C. referential integrity

D. cardinality

Answers:

1) B. It is the data contained in database that is accurate and consistent.
2) All of the above
3) A. inner join
4) D. Select
5) B. weak entity set
6) A. not Null
7) A. is the entire database.
8) C. Relational algebra
9) Child
10) A. Network Model
11) A. SELECT
12) B. Dashed ellipse
13) D. Combination of projection and Cartesian product
14) D. Diamond
15) D. Triangle
16) B. Self Join
17) D. Data redundancy
18) B. data inconsistency
19) C. join
20) B. database constraints

Related Posts:


For More Database Management System(DBMS) MCQs: Click Here

MCQ on Database Design with Answer set-1

Posted at  11:24 م - by mego almasry 0


1) What is a data integrity?

A. It is the data contained in database that is non redundant.

B. It is the data contained in database that is accurate and consistent.

C. It is the data contained in database that is secured.

D. It is the data contained in database that is shared.


2) As per equivalence rules for query transformation, selection operation distributes over

A. Union

B. Intersection

C. Set difference

D. All of the above


3) In SQL the word 'natural' can be used with

A. inner join

B. full outer join

C. right outer join

D. all of the above


4) Which of the following relational algebraic operations is not from set theory?

A. Union

B. Intersection

C. Cartesian Product

D. Select


5) An entity set that does not have sufficient attributes to form a primary key is a

A. strong entity set

B. weak entity set

C. simple entity set

D. primary entity set


6) In case of entity integrity, the primary key may be

A. not Null

B. Null

C. both Null and not Null

D. any value


7) A logical schema

A. is the entire database.

B. is a standard way of organizing information into accessible parts.

C. describes how data is actually stored on disk

D. both A and C


8) Which of the operations constitute a basic set of operations for manipulating relational data?

A. Predicate calculus

B. Relational calculus

C. Relational algebra

D. None of the above


9) Which of the following is another name for weak entity?

A. Child

B. Owner

C. Dominant

D. All of the above


10) Which of the following is record based logical model?

A. Network Model

B. Object oriented model

C. E-R model

D. None of the above



11) A file manipulation command that extracts some of the records from a file is called

A. SELECT

B. PROJECT

C. JOIN

D. PRODUCT


12) In E-R Diagram derived attribute are represented by

A. Ellipse

B. Dashed ellipse

C. Rectangle

D. Triangle


13) The natural join is equal to

A. Cartesian Product

B. Combination of Union and Cartesian product

C. Combination of selection and Cartesian product

D. Combination of projection and Cartesian product


14) In E-R diagram relationship type is represented by

A. Ellipse

B. Dashed ellipse

C. Rectangle

D. Diamond


15) In E-R diagram generalization is represented by

A. Ellipse

B. Dashed ellipse

C. Rectangle

D. Triangle


16) A table joined with itself is called

A. Join

B. Self Join

C. Outer Join

D. Equi Join


17) ........... means multiple copies of the same data items.

A. Data reduction

B. Data integrity

C. Data consistency

D. Data redundancy


18) Different values for the same data item is referred to as .......

A. data consistency

B. data inconsistency

C. data integrity

D. data duplication


19) The .......... returns row after combining two tables based on common values.

A. difference

B. product

C. join

D. union


20) The .......... can be used to ensure database integrity.

A. entity integrity

B. database constraints

C. referential integrity

D. cardinality

Answers:

1) B. It is the data contained in database that is accurate and consistent.
2) All of the above
3) A. inner join
4) D. Select
5) B. weak entity set
6) A. not Null
7) A. is the entire database.
8) C. Relational algebra
9) Child
10) A. Network Model
11) A. SELECT
12) B. Dashed ellipse
13) D. Combination of projection and Cartesian product
14) D. Diamond
15) D. Triangle
16) B. Self Join
17) D. Data redundancy
18) B. data inconsistency
19) C. join
20) B. database constraints

Related Posts:


For More Database Management System(DBMS) MCQs: Click Here


1. Which of the following relational algebra operations do not require the participating tables to be union-compatible?

A. Union

B. Intersection

C. Difference

D. Join


2) Relational Algebra does not have

A. Selection operator

B. Projection operator

C. Aggregation operator

D. Division operator


3) Tree structures are used to store data in

A. Network model

B. Relational model

C. Hierarchical model

D. File based system


4) The rule that a value of a foreign key must appear as a value of some specific table is called a

A. Referential constraint

B. Index

C. Integrity constraint

D. Functional dependency


5) It is an abstraction through which relationships are treated as higher level entities.

A. Generalization

B. Specialization

C. Aggregation

D. Inheritance


6) The operation which is not considered a basic operation of relational algebra is

A. Join

B. Selection

C. Union

D. Cross product


7) In SQL the statement select*from R,S is equivalent to

A. Select * from R natural join S

B. Select * from R cross join S

C. Select * from R union join S

D. Select * from R inner join S


8) When an E-R diagram is mapped to tables, the representation is redundant for

A. Weak entity sets

B. weak relationship sets

C. Strong entity sets

D. strong relationship sets


9) If two relations R and S are joined, then the non matching ruples of both R and S are ignored in

A. left outer join

B. right outer join

C. full outer join

D. inner join


10) Relational Algebra is

A. Data Definition Language

B. Meta Language

C. Procedural query Language

D. None of the above



11) If an entity can belong to only one lower level entity then the constraint is

A. disjoint

B. partial

C. overlapping

D. single


12) The common column is eliminated in

A. theta join

B. outer join

C. natural join

D. composed join


13) In E-R diagram total participation is represented by

A. double lines

B. Dashed lines

C. single line

D. Triangle


14) Relationships among relationships can be represented in an E-R model using

A. Aggregation

B. Association

C. Weak entity sets

D. Weak relationship sets


15) Which of the following constitutes a basic set of operations for manipulating relational data?

A. Predicate calculus

B. Relational calculus

C. Relational algebra

D. SQL


16) Relational calculus is a

A. Procedural language

B. Non-Procedural language

C. Data definition language

D. High level language


17) Cartesian product in relational algebra is

A. a Unary operator

B. a Binary operator

C. a Ternary operator

D. not defined



18) In an E-R diagram attributes are represented by

A. rectangle

B. square

C. ellipse

D. triangle



19) In an E-R diagram an entity set is represent by a

A. rectangle

B. ellipse

C. diamond box

D. circle



20) E-R model uses this symbol to represent weak entity set?

A. Dotted rectangle

B. Diamond

C. Doubly outlined rectangle

D. None of these


Answers:

1) D.Join

2) C. Aggregation operator

3) C. Hierarchical model

4) A. Referential constraint

5) C. Aggregation

6) A. Join

7) B. Select * from R cross join S

8) B. weak relationship sets

9) D. inner join

10) C. Procedural query Language

11) B. partial

12) C. natural join

13) A. double lines

14) A. Aggregation

15) C. Relational algebra

16) B. Non-Procedural language

17) B. a Binary operator

18) C. ellipse

19) A. rectangle

20) C. Doubly outlined rectangle


Related Posts:


For More Database Management System(DBMS) MCQs: Click Here

Objective Questions on Relational Algebra with Answer set-1

Posted at  12:42 ص - by mego almasry 0


1. Which of the following relational algebra operations do not require the participating tables to be union-compatible?

A. Union

B. Intersection

C. Difference

D. Join


2) Relational Algebra does not have

A. Selection operator

B. Projection operator

C. Aggregation operator

D. Division operator


3) Tree structures are used to store data in

A. Network model

B. Relational model

C. Hierarchical model

D. File based system


4) The rule that a value of a foreign key must appear as a value of some specific table is called a

A. Referential constraint

B. Index

C. Integrity constraint

D. Functional dependency


5) It is an abstraction through which relationships are treated as higher level entities.

A. Generalization

B. Specialization

C. Aggregation

D. Inheritance


6) The operation which is not considered a basic operation of relational algebra is

A. Join

B. Selection

C. Union

D. Cross product


7) In SQL the statement select*from R,S is equivalent to

A. Select * from R natural join S

B. Select * from R cross join S

C. Select * from R union join S

D. Select * from R inner join S


8) When an E-R diagram is mapped to tables, the representation is redundant for

A. Weak entity sets

B. weak relationship sets

C. Strong entity sets

D. strong relationship sets


9) If two relations R and S are joined, then the non matching ruples of both R and S are ignored in

A. left outer join

B. right outer join

C. full outer join

D. inner join


10) Relational Algebra is

A. Data Definition Language

B. Meta Language

C. Procedural query Language

D. None of the above



11) If an entity can belong to only one lower level entity then the constraint is

A. disjoint

B. partial

C. overlapping

D. single


12) The common column is eliminated in

A. theta join

B. outer join

C. natural join

D. composed join


13) In E-R diagram total participation is represented by

A. double lines

B. Dashed lines

C. single line

D. Triangle


14) Relationships among relationships can be represented in an E-R model using

A. Aggregation

B. Association

C. Weak entity sets

D. Weak relationship sets


15) Which of the following constitutes a basic set of operations for manipulating relational data?

A. Predicate calculus

B. Relational calculus

C. Relational algebra

D. SQL


16) Relational calculus is a

A. Procedural language

B. Non-Procedural language

C. Data definition language

D. High level language


17) Cartesian product in relational algebra is

A. a Unary operator

B. a Binary operator

C. a Ternary operator

D. not defined



18) In an E-R diagram attributes are represented by

A. rectangle

B. square

C. ellipse

D. triangle



19) In an E-R diagram an entity set is represent by a

A. rectangle

B. ellipse

C. diamond box

D. circle



20) E-R model uses this symbol to represent weak entity set?

A. Dotted rectangle

B. Diamond

C. Doubly outlined rectangle

D. None of these


Answers:

1) D.Join

2) C. Aggregation operator

3) C. Hierarchical model

4) A. Referential constraint

5) C. Aggregation

6) A. Join

7) B. Select * from R cross join S

8) B. weak relationship sets

9) D. inner join

10) C. Procedural query Language

11) B. partial

12) C. natural join

13) A. double lines

14) A. Aggregation

15) C. Relational algebra

16) B. Non-Procedural language

17) B. a Binary operator

18) C. ellipse

19) A. rectangle

20) C. Doubly outlined rectangle


Related Posts:


For More Database Management System(DBMS) MCQs: Click Here

الأربعاء، 3 ديسمبر 2014


1) DROP is a ................ statement in SQL.

A. Query

B. Embedded SQL

C. DDL

D. DCL


2) The keyword to eliminate duplicate rows from the query result in SQL is.

A. DISTINCT

B. NO DUPLICATE

C. UNIQUE

D. None of the above


3) Which of the following aggregate function does not ignore nulls in its results?

A. COUNT

B. COUNT(*)

C. MAX

D. MIN


4) In SQL, testing whether a subquery is empty is done using

A. DISTINCT

B. UNIQUE

C. NULL

D. EXISTS


5) ................ operator is used to compare a value to a list of literals values that have been specified.

A. Like

B. Compare

C. Between

D. In


6) The language used in application programs to request data from the DBMS is referred to as the

A. DML

B. DDL

C. VDL

D. SDL


7) The DBMS language component which can be embedded in a program is

A. The data definition language(DDL)

B. The data manipulation language(DML)

C. The database administrator(DBA)

D. A query language


8) A DBMS query language is designed to

A. Support end users who use English-like commands.

B. Support in the development of complex applications software.

C. Specify the structure of a database.

D. All of the above


9) It is possible to define a schema completely using.

A. VDL and DDL

B. DDL and DML

C. SDL and DDL

D. VDL and DML


10) Which of the following is correct.

A. a SQL query automatically eliminates duplicates.

B. SQL permits attribute names to be repeated in the same relation.

C. a SQL query will not work if there are no indexes on the relations.

D. None of these.



11) Which of the following is a comparison operator in SQL?

A. =

B. LIKE

C. BETWEEN

D. All of the above


12) To delete a particular column in a relation the command used is.

A. UPDATE

B. DROP

C. ALTER

D. DELETE


13) The ............ operator is used to compare the value to a list of literals values that that have been specified.

A. BETWEEN

B. ANY

C) IN

D) ALL


14) ............ function divides one numeric expression by another and returns the remainder.

A. POWER

B. MOD

C. ROUND

D. REMAINDER


15) A data manipulation command the combines the record from one or more tables is called.

A) SELECT

B. PROJECT

C. JOIN

D. PRODUCT


16) DDL stands for

A. Data definition language

B. Data description language

C. Data design languages

D. Database dictionary languages.


17) The DDL is used to specify the ........

A. Conceptual schema

B. Internal schema

C. Both

D. None


18) Which is used for data retrieval from the database?

A. DDL

B. DML

C. SDL

D. VDL


19) Which is used to specify the user views and their mappings to the conceptual schema?

A. DDL

B. DML

C. SDL

D. VDL


20) Which command are included in a general purpose programming languages?

A. DDL

B. DML

C. DSL

D. VDL

Answers:

1) C. DDL

2) C. UNIQUE

3) B. COUNT(*)

4) D. EXISTS

5) A. Like

6) A. DML

7) B. The data manipulation language(DML)

8) D. All of the above

9) B. DDL and DML

10) D. None of these.

11) D. All of the above

12) C. ALTER

13) A. BETWEEN

14) B. MOD

15) C. JOIN

16) A. Data definition language

17) A.Conceptual schema

18) B.DML

19) D.VDL

20) B.DML

Solved Objective Questions on SQL and Embedded SQL set-5

Posted at  9:07 م - by mego almasry 0


1) DROP is a ................ statement in SQL.

A. Query

B. Embedded SQL

C. DDL

D. DCL


2) The keyword to eliminate duplicate rows from the query result in SQL is.

A. DISTINCT

B. NO DUPLICATE

C. UNIQUE

D. None of the above


3) Which of the following aggregate function does not ignore nulls in its results?

A. COUNT

B. COUNT(*)

C. MAX

D. MIN


4) In SQL, testing whether a subquery is empty is done using

A. DISTINCT

B. UNIQUE

C. NULL

D. EXISTS


5) ................ operator is used to compare a value to a list of literals values that have been specified.

A. Like

B. Compare

C. Between

D. In


6) The language used in application programs to request data from the DBMS is referred to as the

A. DML

B. DDL

C. VDL

D. SDL


7) The DBMS language component which can be embedded in a program is

A. The data definition language(DDL)

B. The data manipulation language(DML)

C. The database administrator(DBA)

D. A query language


8) A DBMS query language is designed to

A. Support end users who use English-like commands.

B. Support in the development of complex applications software.

C. Specify the structure of a database.

D. All of the above


9) It is possible to define a schema completely using.

A. VDL and DDL

B. DDL and DML

C. SDL and DDL

D. VDL and DML


10) Which of the following is correct.

A. a SQL query automatically eliminates duplicates.

B. SQL permits attribute names to be repeated in the same relation.

C. a SQL query will not work if there are no indexes on the relations.

D. None of these.



11) Which of the following is a comparison operator in SQL?

A. =

B. LIKE

C. BETWEEN

D. All of the above


12) To delete a particular column in a relation the command used is.

A. UPDATE

B. DROP

C. ALTER

D. DELETE


13) The ............ operator is used to compare the value to a list of literals values that that have been specified.

A. BETWEEN

B. ANY

C) IN

D) ALL


14) ............ function divides one numeric expression by another and returns the remainder.

A. POWER

B. MOD

C. ROUND

D. REMAINDER


15) A data manipulation command the combines the record from one or more tables is called.

A) SELECT

B. PROJECT

C. JOIN

D. PRODUCT


16) DDL stands for

A. Data definition language

B. Data description language

C. Data design languages

D. Database dictionary languages.


17) The DDL is used to specify the ........

A. Conceptual schema

B. Internal schema

C. Both

D. None


18) Which is used for data retrieval from the database?

A. DDL

B. DML

C. SDL

D. VDL


19) Which is used to specify the user views and their mappings to the conceptual schema?

A. DDL

B. DML

C. SDL

D. VDL


20) Which command are included in a general purpose programming languages?

A. DDL

B. DML

C. DSL

D. VDL

Answers:

1) C. DDL

2) C. UNIQUE

3) B. COUNT(*)

4) D. EXISTS

5) A. Like

6) A. DML

7) B. The data manipulation language(DML)

8) D. All of the above

9) B. DDL and DML

10) D. None of these.

11) D. All of the above

12) C. ALTER

13) A. BETWEEN

14) B. MOD

15) C. JOIN

16) A. Data definition language

17) A.Conceptual schema

18) B.DML

19) D.VDL

20) B.DML

الاثنين، 24 نوفمبر 2014


JavaScript makes more easier to manipulate websites, now a days most of the browsers supporting JavaScript codes. When the HTML parser encounters a <script> element, by default, run the script before it can parsing and rendering the document. It is not much problem for inline scripts but if the script source code is in an external file specified with a src attribute, the portions of the document that follow the Script will not appear in the browser until the script has been downloaded and executed.This makes loading of the website much slower, which makes bad user experience for your website and may not also indexing of your website by the search engines.


This Synchronous or blocking script execution is the default only. The <script> tag can have defer and async attributes, which cause scripts to be executed differently. This makes your website loading much faster than before and appears contents of your site by loading at first.


Loading JavaScript Asynchronously using async or defer attributes



Both the defer and acync attributes are ways of telling the browser that the linked script does not use document.write() and won't be generating document content, and that therefore the browser can continue to parse and render the document while downloading the script. You can use async or defer attributes as the following.
<script defer src="deferred.js"></script> 
<script async src="async.js"></script>

The defer attribute causes the browser to defer execution of the script until after the document has been loaded and parsed and is ready to be manipulated. The async attribute causes the browser to run the script as soon as possible but not to block document parsing while the script is being downloaded. If a <script> tag has both attributes, a browser that supports both will honor the async attribute and ignore the defer attribute. Deferred scripts run in the order in which they appear in the document, while acync scripts run as they load, which means that they may execute out of order.

Here is an example of acync script uses in this blog for Intensedebate comments script source.

<script async='async' expr:src='data:post.commentSrc' type='text/javascript'/>



Loading JavaScript Asynchronously by loading scripts dynamically



You can load and execute scripts asynchronously, even in browsers that do not support the async attribute, by dynamically creating a <script> element and inserting it into the document. Here is an example how to load scripts dynamically.

function loadasync(url){
var head=document.getElementByTagName("head")[0];
var s=document.createElement("script");
s.src=url;
head.appendchild(s);
}

This loadsaync() function finds the <head> tag and attach <script> tag below opening of head tag and loads scripts dynamically. Scripts that are neither included inline within the web page or referenced statically from the web page are loaded into the document and become part of the running JavaScript program.

You can use the following method to execute loadsync() function, when document finished loading.

function loadasync(){ ..................}
request.onreadystatechange=loadasync;

Here is an example of loading JavaScript asynchronously by loading scripts dynamically used in this blog for external scripts from infolinks ads.

<div style='display:none'>  <div id='adsource-0'>
<script type='text/javascript'>
var infolinks_pid = 9993182;
var infolinks_wsid = 1;
</script>
<script language='javascript' src='http://resources.infolinks.com/js/infolinks_main.js' type='text/javascript'/>
</div>
</div>
<script type='text/javascript'>
source = document.getElementById("adsource-0");
placeholder = document.getElementById("ad-0");
placeholder.appendChild(source);
</script>

I have placed this code at the bottom of HTML codes, i.e. just before </body> tag and have placed the following code where I want to display ads.

<div id="ad-0" align="center"></div>


Loading JavaScript Asynchronously when document finishes loading 




You can load and execute scripts asynchronously by using setTimeout(), addEventListner(), and attachEvent(). Most objects that can be event targets have a method named addEventListner(), which allows the registration of multiple listeners.

window.addEventListner("load", function(){.....},false);
request.addEventListner("readystatechange", function(){......},false);

The first argument to this function is the name of the event. For IE8 and earlier, you must use a similar method, named attachEvent().

window.attachevent("onload", function() {.....});

Here is an example which define an onLoad() function that registers a function to be run when the document finishes loading. If the document has already loaded, run it asynchronously.

function onLoad(f){
if(onLoad.loaded)
window.setTimeout(f,0);
elseif (window.addEventListner)
window.addEventListner("load",f,false);
elseif (window.attachEvent)
window.attachEvent("onload",f);
}

onLoad.loaded=false;

onLoad(function(){onLoad.loaded=true;});


In the above script window.attachEvent is used for IE8 and earlier. onLoad.loaded=false; sets a flag that indicates the document is not loaded yet and onLoad(function(){onLoad.loaded=true;}); register a function to set the flag when the document does load.



Related Posts:



How to Load External JavaScript Asynchronously or Dynamically

Posted at  9:34 م - by mego almasry 0


JavaScript makes more easier to manipulate websites, now a days most of the browsers supporting JavaScript codes. When the HTML parser encounters a <script> element, by default, run the script before it can parsing and rendering the document. It is not much problem for inline scripts but if the script source code is in an external file specified with a src attribute, the portions of the document that follow the Script will not appear in the browser until the script has been downloaded and executed.This makes loading of the website much slower, which makes bad user experience for your website and may not also indexing of your website by the search engines.


This Synchronous or blocking script execution is the default only. The <script> tag can have defer and async attributes, which cause scripts to be executed differently. This makes your website loading much faster than before and appears contents of your site by loading at first.


Loading JavaScript Asynchronously using async or defer attributes



Both the defer and acync attributes are ways of telling the browser that the linked script does not use document.write() and won't be generating document content, and that therefore the browser can continue to parse and render the document while downloading the script. You can use async or defer attributes as the following.
<script defer src="deferred.js"></script> 
<script async src="async.js"></script>

The defer attribute causes the browser to defer execution of the script until after the document has been loaded and parsed and is ready to be manipulated. The async attribute causes the browser to run the script as soon as possible but not to block document parsing while the script is being downloaded. If a <script> tag has both attributes, a browser that supports both will honor the async attribute and ignore the defer attribute. Deferred scripts run in the order in which they appear in the document, while acync scripts run as they load, which means that they may execute out of order.

Here is an example of acync script uses in this blog for Intensedebate comments script source.

<script async='async' expr:src='data:post.commentSrc' type='text/javascript'/>



Loading JavaScript Asynchronously by loading scripts dynamically



You can load and execute scripts asynchronously, even in browsers that do not support the async attribute, by dynamically creating a <script> element and inserting it into the document. Here is an example how to load scripts dynamically.

function loadasync(url){
var head=document.getElementByTagName("head")[0];
var s=document.createElement("script");
s.src=url;
head.appendchild(s);
}

This loadsaync() function finds the <head> tag and attach <script> tag below opening of head tag and loads scripts dynamically. Scripts that are neither included inline within the web page or referenced statically from the web page are loaded into the document and become part of the running JavaScript program.

You can use the following method to execute loadsync() function, when document finished loading.

function loadasync(){ ..................}
request.onreadystatechange=loadasync;

Here is an example of loading JavaScript asynchronously by loading scripts dynamically used in this blog for external scripts from infolinks ads.

<div style='display:none'>  <div id='adsource-0'>
<script type='text/javascript'>
var infolinks_pid = 9993182;
var infolinks_wsid = 1;
</script>
<script language='javascript' src='http://resources.infolinks.com/js/infolinks_main.js' type='text/javascript'/>
</div>
</div>
<script type='text/javascript'>
source = document.getElementById("adsource-0");
placeholder = document.getElementById("ad-0");
placeholder.appendChild(source);
</script>

I have placed this code at the bottom of HTML codes, i.e. just before </body> tag and have placed the following code where I want to display ads.

<div id="ad-0" align="center"></div>


Loading JavaScript Asynchronously when document finishes loading 




You can load and execute scripts asynchronously by using setTimeout(), addEventListner(), and attachEvent(). Most objects that can be event targets have a method named addEventListner(), which allows the registration of multiple listeners.

window.addEventListner("load", function(){.....},false);
request.addEventListner("readystatechange", function(){......},false);

The first argument to this function is the name of the event. For IE8 and earlier, you must use a similar method, named attachEvent().

window.attachevent("onload", function() {.....});

Here is an example which define an onLoad() function that registers a function to be run when the document finishes loading. If the document has already loaded, run it asynchronously.

function onLoad(f){
if(onLoad.loaded)
window.setTimeout(f,0);
elseif (window.addEventListner)
window.addEventListner("load",f,false);
elseif (window.attachEvent)
window.attachEvent("onload",f);
}

onLoad.loaded=false;

onLoad(function(){onLoad.loaded=true;});


In the above script window.attachEvent is used for IE8 and earlier. onLoad.loaded=false; sets a flag that indicates the document is not loaded yet and onLoad(function(){onLoad.loaded=true;}); register a function to set the flag when the document does load.



Related Posts:



الاثنين، 17 نوفمبر 2014


Most of our visitors asked "How to Add Multiple Slideshows on One Page Using JavaScript" by commenting on different previous posts for JavaScript slideshow and going to write this post about to add multiple slideshows on the same page. Using this script you can add number of slideshows on single page as your requirements. 


Multiple Slideshows on One Page Using JavaScript



To make multiple slideshows, at first you have to make variable lists for each slideshows and have to create new slideshow using function slideshow( ). Here I have created two slideshows with variables SlideList1 and SlideList2 and uses function slideshow with parameters slideList, image, speed and name.

You can create number of new slideshows using this function below using new keyword. i.e. var slideshow1=new slideshow(slideList1, 'slide1', 3000, 'slideshow1');

function SlideShow(slideList, image, speed, name)          
{
this.slideList = slideList;
this.image = image;
this.speed = speed;
this.name = name;
this.current = 0;
this.timer = 0;
}

And the another function switchImage( ) given below allows you to  change images while playing slideshows.

function switchImage(imgName, imgSrc) 
{
if (document.images)
{
if (imgSrc != "none")
{
document.images[imgName].src = imgSrc;
}
}
}

Here is a full JavaScript code for making multiple slideshows on one page using JavaScript. Copy the following codes inside body tag of your HTML file and replace given image source <img src=" "> with your image source.


<img src="image1.gif" name="slide1">
<img src="image2.gif" name="slide2">
<script type=text/javascript>
var SlideList1 = ['image1.gif', 'image2.gif', 'image3.gif'];
var SlideShow1 = new SlideShow(SlideList1, 'slide1', 3000, "SlideShow1");
var SlideList2 = ['image4.gif', 'image5.gif', 'image6.gif'];
var SlideShow2 = new SlideShow(SlideList2, 'slide2', 1000, "SlideShow2");
function SlideShow(slideList, image, speed, name)
{
this.slideList = slideList;
this.image = image;
this.speed = speed;
this.name = name;
this.current = 0;
this.timer = 0;
}
function switchImage(imgName, imgSrc)
{
if (document.images)
{
if (imgSrc != "none")
{
document.images[imgName].src = imgSrc;
}
}
}
SlideShow.prototype.play = SlideShow_play;
function SlideShow_play()
{
with(this)
{
if(current++ == slideList.length-1) current = 0;
switchImage(image, slideList[current]);
clearTimeout(timer);
timer = setTimeout(name+'.play()', speed);
}
}
window.onLoad=SlideShow1.play();SlideShow2.play();
</script>


Here the speed of first and second slideshows are specified 3000 and 1000 respectively, your can change them as your requirements. Also you can add more slideshows by adding more slideList and slideshow variables.


Preview of  JavaScript Code Given Above



slide1

slide2



You can add custom CSS codes to give different styles like setting border using border: property, give rounded corners using border-radius property as presented in the previous post "How to make rounded corners border using CSS" and can give different animation effects like fade effects, zoom effects, slide effects etc. 

You can refer to the following previous posts to give fade effect animations using CSS, JavaScript or JQuery codes.



Related Posts:






How to Add Multiple Slideshows on One Page Using Javascript

Posted at  10:37 م - by mego almasry 0


Most of our visitors asked "How to Add Multiple Slideshows on One Page Using JavaScript" by commenting on different previous posts for JavaScript slideshow and going to write this post about to add multiple slideshows on the same page. Using this script you can add number of slideshows on single page as your requirements. 


Multiple Slideshows on One Page Using JavaScript



To make multiple slideshows, at first you have to make variable lists for each slideshows and have to create new slideshow using function slideshow( ). Here I have created two slideshows with variables SlideList1 and SlideList2 and uses function slideshow with parameters slideList, image, speed and name.

You can create number of new slideshows using this function below using new keyword. i.e. var slideshow1=new slideshow(slideList1, 'slide1', 3000, 'slideshow1');

function SlideShow(slideList, image, speed, name)          
{
this.slideList = slideList;
this.image = image;
this.speed = speed;
this.name = name;
this.current = 0;
this.timer = 0;
}

And the another function switchImage( ) given below allows you to  change images while playing slideshows.

function switchImage(imgName, imgSrc) 
{
if (document.images)
{
if (imgSrc != "none")
{
document.images[imgName].src = imgSrc;
}
}
}

Here is a full JavaScript code for making multiple slideshows on one page using JavaScript. Copy the following codes inside body tag of your HTML file and replace given image source <img src=" "> with your image source.


<img src="image1.gif" name="slide1">
<img src="image2.gif" name="slide2">
<script type=text/javascript>
var SlideList1 = ['image1.gif', 'image2.gif', 'image3.gif'];
var SlideShow1 = new SlideShow(SlideList1, 'slide1', 3000, "SlideShow1");
var SlideList2 = ['image4.gif', 'image5.gif', 'image6.gif'];
var SlideShow2 = new SlideShow(SlideList2, 'slide2', 1000, "SlideShow2");
function SlideShow(slideList, image, speed, name)
{
this.slideList = slideList;
this.image = image;
this.speed = speed;
this.name = name;
this.current = 0;
this.timer = 0;
}
function switchImage(imgName, imgSrc)
{
if (document.images)
{
if (imgSrc != "none")
{
document.images[imgName].src = imgSrc;
}
}
}
SlideShow.prototype.play = SlideShow_play;
function SlideShow_play()
{
with(this)
{
if(current++ == slideList.length-1) current = 0;
switchImage(image, slideList[current]);
clearTimeout(timer);
timer = setTimeout(name+'.play()', speed);
}
}
window.onLoad=SlideShow1.play();SlideShow2.play();
</script>


Here the speed of first and second slideshows are specified 3000 and 1000 respectively, your can change them as your requirements. Also you can add more slideshows by adding more slideList and slideshow variables.


Preview of  JavaScript Code Given Above



slide1

slide2



You can add custom CSS codes to give different styles like setting border using border: property, give rounded corners using border-radius property as presented in the previous post "How to make rounded corners border using CSS" and can give different animation effects like fade effects, zoom effects, slide effects etc. 

You can refer to the following previous posts to give fade effect animations using CSS, JavaScript or JQuery codes.



Related Posts:






الخميس، 13 نوفمبر 2014


You can give fade effect animation for image slideshow using CSS. @keyframes 'at' rule and animation keyword in CSS can be used to make image slideshow with fade effect. With @keyframes 'at' rule, you can define the properties that will be animated in an animation rule and animation keyword to set all of the animation properties.


Here I have used different types of animation properties like animation-name, animation-duration, animation-timing-function and animation-iteration-count. Where animation-name specifies name of the animation, animation-duration specifies animation duration in second(s) or milisecond(ms), animation-timing-function specifies how the animation will play like ease, ease-in, ease-in-out, ease-out and linear and animation-iteration-count:number of times animation should play.

Simple fade effect image slideshow 

 
Here is a sample CSS code for creating simple fade effect image slideshow written for safari browser.

<style type="text/css">
@-webkit-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
#anim1 {-webkit-animation-name:fade;-webkit-animation-duration:5s;
-webkit-animation-iteration-timing-function:linear;
position:relative;-webkit-animation-iteration-count:infinite;}
</style>

Here is a full HTML code along with required JavaScript code for creating simple fade effect image slideshow.

<head>
<title>CSS Animations</title>
<style type="text/css">
@-webkit-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
@-moz-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
@-o-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
@-ms-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
#anim1 {-webkit-animation-name:fade;-webkit-animation-duration:5s;
-webkit-animation-iteration-timing-function:linear;position:relative;
-webkit-animation-iteration-count:infinite;-moz-animation-name:fade;
-moz-animation-duration:5s;-moz-animation-iteration-timing-function:linear;
-moz-animation-iteration-count:infinite;-o-animation-name:fade;
-o-animation-duration:5s;-o-animation-iteration-timing-function:linear;
-o-animation-iteration-count:infinite;-ms-animation-name:fade;
-ms-animation-duration:5s;-ms-animation-iteration-timing-function:linear;
-ms-animation-iteration-count:infinite;}
</style>
<script language="JavaScript">
var i = 0;
var path = new Array();

// LIST OF IMAGES
path[0] = "image1.jpg";
path[1] = "image2.jpg";
path[2] = "image3.jpg";

function swapImage1()
{
document.slide.src = path[i];
if(i < path.length - 1) i++; else i = 0;
setTimeout("swapImage1()",5000);
}
window.onload=swapImage1;
</script>
</head>
<body>
<div id="anim1"><img height="400" name="slide" src="image_1.gif" width="600" />
</div>
</body>
</html>


In the above code prefixes -webkit-, -moz-, -o-, -ms- are used for browsers safari, firefox, opera and internet explorer respectively.

Here is a preview of image slideshow for the code above.


slide


Fade effect image slideshow with caption


You can add caption for this slideshow by adding following JavaScript codes within <script> tag.


// LIST OF CAPTİONS  

caption[0] = "Caption for the first image";

caption[1] = "Caption for the second image";

caption[2] = "Caption for the third image";

function swapImage(){

var el = document.getElementById("mydiv");

el.innerHTML=caption[i];

var img= document.getElementById("anim1");

img.src= image[i];

if(i <k ) { i++;}

else { i = 0; }



For details on adding caption on image slideshow visit the post: How To Create Simple Image Slideshow Using JavaScript ?


Fade effect image slideshow with caption and link


You can add caption for this slideshow by adding following JavaScript codes within <script> tag.



var link= new Array();   

link[0] = "http://www.siteforinfotech.com/";
link[1] = "http://www.siteforinfotech.com/p/tutorial.html";
link[2] = "http://www.siteforinfotech.com/p/mcqs.html";


function swapImage(){

var el = document.getElementById("mydiv");

el.innerHTML=caption[i];

var img= document.getElementById("anim1");

img.src= image[i];

var a = document.getElementById("link");
a.href= link[i];

if(i <k ) { i++;}

else { i = 0; }



For details on adding caption and link on image slideshow visit the post: How to Create JavaScript Image Slideshow with Links



Related Posts:

How to create fade effect image slideshow using CSS

Posted at  1:45 ص - by mego almasry 0


You can give fade effect animation for image slideshow using CSS. @keyframes 'at' rule and animation keyword in CSS can be used to make image slideshow with fade effect. With @keyframes 'at' rule, you can define the properties that will be animated in an animation rule and animation keyword to set all of the animation properties.


Here I have used different types of animation properties like animation-name, animation-duration, animation-timing-function and animation-iteration-count. Where animation-name specifies name of the animation, animation-duration specifies animation duration in second(s) or milisecond(ms), animation-timing-function specifies how the animation will play like ease, ease-in, ease-in-out, ease-out and linear and animation-iteration-count:number of times animation should play.

Simple fade effect image slideshow 

 
Here is a sample CSS code for creating simple fade effect image slideshow written for safari browser.

<style type="text/css">
@-webkit-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
#anim1 {-webkit-animation-name:fade;-webkit-animation-duration:5s;
-webkit-animation-iteration-timing-function:linear;
position:relative;-webkit-animation-iteration-count:infinite;}
</style>

Here is a full HTML code along with required JavaScript code for creating simple fade effect image slideshow.

<head>
<title>CSS Animations</title>
<style type="text/css">
@-webkit-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
@-moz-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
@-o-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
@-ms-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
#anim1 {-webkit-animation-name:fade;-webkit-animation-duration:5s;
-webkit-animation-iteration-timing-function:linear;position:relative;
-webkit-animation-iteration-count:infinite;-moz-animation-name:fade;
-moz-animation-duration:5s;-moz-animation-iteration-timing-function:linear;
-moz-animation-iteration-count:infinite;-o-animation-name:fade;
-o-animation-duration:5s;-o-animation-iteration-timing-function:linear;
-o-animation-iteration-count:infinite;-ms-animation-name:fade;
-ms-animation-duration:5s;-ms-animation-iteration-timing-function:linear;
-ms-animation-iteration-count:infinite;}
</style>
<script language="JavaScript">
var i = 0;
var path = new Array();

// LIST OF IMAGES
path[0] = "image1.jpg";
path[1] = "image2.jpg";
path[2] = "image3.jpg";

function swapImage1()
{
document.slide.src = path[i];
if(i < path.length - 1) i++; else i = 0;
setTimeout("swapImage1()",5000);
}
window.onload=swapImage1;
</script>
</head>
<body>
<div id="anim1"><img height="400" name="slide" src="image_1.gif" width="600" />
</div>
</body>
</html>


In the above code prefixes -webkit-, -moz-, -o-, -ms- are used for browsers safari, firefox, opera and internet explorer respectively.

Here is a preview of image slideshow for the code above.


slide


Fade effect image slideshow with caption


You can add caption for this slideshow by adding following JavaScript codes within <script> tag.


// LIST OF CAPTİONS  

caption[0] = "Caption for the first image";

caption[1] = "Caption for the second image";

caption[2] = "Caption for the third image";

function swapImage(){

var el = document.getElementById("mydiv");

el.innerHTML=caption[i];

var img= document.getElementById("anim1");

img.src= image[i];

if(i <k ) { i++;}

else { i = 0; }



For details on adding caption on image slideshow visit the post: How To Create Simple Image Slideshow Using JavaScript ?


Fade effect image slideshow with caption and link


You can add caption for this slideshow by adding following JavaScript codes within <script> tag.



var link= new Array();   

link[0] = "http://www.siteforinfotech.com/";
link[1] = "http://www.siteforinfotech.com/p/tutorial.html";
link[2] = "http://www.siteforinfotech.com/p/mcqs.html";


function swapImage(){

var el = document.getElementById("mydiv");

el.innerHTML=caption[i];

var img= document.getElementById("anim1");

img.src= image[i];

var a = document.getElementById("link");
a.href= link[i];

if(i <k ) { i++;}

else { i = 0; }



For details on adding caption and link on image slideshow visit the post: How to Create JavaScript Image Slideshow with Links



Related Posts:

الثلاثاء، 4 نوفمبر 2014


While designing website, website template or blog template, you may want to make buttons, menus, paragraphs or any others border corners rounded to make your template more beautiful and attractive. It is possible by using a keyword "border-radius" in CSS. The keyword border-radius is used to make all the corners rounded by specifying the radius of corner. For example you can use the following CSS code.
rounded corners border using CSS

border-radius:10px;                    // makes radius of all the corners 10px;

You can also specify the radius for each corners by using border-radius-top-right, border-radius-top-left, border-radius-bottom-right, border-radius-bottom-left keywords. For example you can use the following CSS code to make each corner rounded.

border-radius-top-right:10px;
border-radius-top-left:10px;
border-radius-bottom-right:5px;
border-radius-bottom-left:5px;

The above code makes radius of left and right corners of top side 10px and radius of left and right corners of bottom side 5px.

To makes this CSS code browser specific or specific browser compatible, you have to use the prefix codes like -moz- for mozilla firefox and -webkit- for chrome or safari.


.all{

border:2px solid red;

-moz-border-radius:10px;

-webkit-border-radius:10px;

border-radius:10px;

width:250px;

}

.topleft{

border:2px solid red;

-moz-border-top-left-radius:10px;

-webkit-border-top-left-radius:10px;

border-top-left-radius:10px;

width:250px;

}

.topright{

border:2px solid red;

-moz-border-top-right-radius:10px;

-webkit-border-top-right-radius:10px;

border-top-right-radius:10px;

width:250px;

}

.bottomleft{

border:2px solid red;

-moz-border-bottom-left-radius:10px;

-webkit-border-top-left-radius:10px;

border-bottom-left-radius:10px;

width:250px;

}

.bottomright{

border:2px solid red;

-moz-border-bottom-right-radius:10px;

-webkit-border-bottom-right-radius:10px;

border-bottom-right-radius:10px;

width:250px;

}


Use above CSS code with the following HTML code given.

<html>
<head>
<title>CSS code for rounded corners</title>
<style type="text/css">

//place the abobe CSS code

</style>
</head>
<body>
<div class="all">All rounded corners</div>
</br>
<div class="topleft">Topleft rounded corner</div>
<br/>
<div class="topright">Topright rounded corner</div>
</br>
<div class="bottomleft">Bottomleft rounded corner</div>
<br/>
<div class="bottomright">Bottomright rounded corner</div>
</body>
</html>

You can view the following rounded corners for 2px solid red border and 250px width having 10px radius of corners.


All rounded corners

Topleft rounded corner

Topright rounded corner

Bottomleft rounded corner

Bottomright rounded corner


Here I have used <div> tag, so these shapes are appeared with line break. If you wanted to place these shapes on the same line you can use <span> tag. You can also use <p> tag with the place of <div> tag.

You can apply these rounded corners shapes to make CSS buttons, menus etc. Here is a sample code to make CSS button along with background color.

<div style="border:2px solid light-blue; -moz-border-radius:10px;
background-color:blue; z-index:10;-webkit-border-radius:10px;
border-radius:10px;width:110px;text-align:center;
color:white;cursor:pointer;">
CSS button
</div>




Related Posts:



How to make rounded corners border using CSS

Posted at  1:37 ص - by mego almasry 0


While designing website, website template or blog template, you may want to make buttons, menus, paragraphs or any others border corners rounded to make your template more beautiful and attractive. It is possible by using a keyword "border-radius" in CSS. The keyword border-radius is used to make all the corners rounded by specifying the radius of corner. For example you can use the following CSS code.
rounded corners border using CSS

border-radius:10px;                    // makes radius of all the corners 10px;

You can also specify the radius for each corners by using border-radius-top-right, border-radius-top-left, border-radius-bottom-right, border-radius-bottom-left keywords. For example you can use the following CSS code to make each corner rounded.

border-radius-top-right:10px;
border-radius-top-left:10px;
border-radius-bottom-right:5px;
border-radius-bottom-left:5px;

The above code makes radius of left and right corners of top side 10px and radius of left and right corners of bottom side 5px.

To makes this CSS code browser specific or specific browser compatible, you have to use the prefix codes like -moz- for mozilla firefox and -webkit- for chrome or safari.


.all{

border:2px solid red;

-moz-border-radius:10px;

-webkit-border-radius:10px;

border-radius:10px;

width:250px;

}

.topleft{

border:2px solid red;

-moz-border-top-left-radius:10px;

-webkit-border-top-left-radius:10px;

border-top-left-radius:10px;

width:250px;

}

.topright{

border:2px solid red;

-moz-border-top-right-radius:10px;

-webkit-border-top-right-radius:10px;

border-top-right-radius:10px;

width:250px;

}

.bottomleft{

border:2px solid red;

-moz-border-bottom-left-radius:10px;

-webkit-border-top-left-radius:10px;

border-bottom-left-radius:10px;

width:250px;

}

.bottomright{

border:2px solid red;

-moz-border-bottom-right-radius:10px;

-webkit-border-bottom-right-radius:10px;

border-bottom-right-radius:10px;

width:250px;

}


Use above CSS code with the following HTML code given.

<html>
<head>
<title>CSS code for rounded corners</title>
<style type="text/css">

//place the abobe CSS code

</style>
</head>
<body>
<div class="all">All rounded corners</div>
</br>
<div class="topleft">Topleft rounded corner</div>
<br/>
<div class="topright">Topright rounded corner</div>
</br>
<div class="bottomleft">Bottomleft rounded corner</div>
<br/>
<div class="bottomright">Bottomright rounded corner</div>
</body>
</html>

You can view the following rounded corners for 2px solid red border and 250px width having 10px radius of corners.


All rounded corners

Topleft rounded corner

Topright rounded corner

Bottomleft rounded corner

Bottomright rounded corner


Here I have used <div> tag, so these shapes are appeared with line break. If you wanted to place these shapes on the same line you can use <span> tag. You can also use <p> tag with the place of <div> tag.

You can apply these rounded corners shapes to make CSS buttons, menus etc. Here is a sample code to make CSS button along with background color.

<div style="border:2px solid light-blue; -moz-border-radius:10px;
background-color:blue; z-index:10;-webkit-border-radius:10px;
border-radius:10px;width:110px;text-align:center;
color:white;cursor:pointer;">
CSS button
</div>




Related Posts:



Copyright © 2013 hello1. by Bloggertheme9 Powered by Blogger.
WP Theme-junkie converted by Blogger template