Friday, June 12, 2009

Quirks mode and strict mode

The structure and appearance of a web page is described by a combination of two standardized languages:HTML, a markup language designed for web use, which describes the structure and content of the page, and CSS, a generalized stylesheet language, which specifies how the page should be rendered in various media (visual styles for screen display, print styles to use when printing the page, aural styles to use when the page is read aloud by a screen reader, etc.). However, most older web browsers either did not fully implement the specifications for these languages or were developed prior to the finalization of the specifications (Internet Explorer version 5.0 was the first major web browser with full support for CSS Level 1, for example).[1] As a result, many older web pages were constructed to rely upon the older browsers' incomplete or incorrect implementations, and will only render as intended when handled by such a browser.
Support for standardized HTML and CSS in major web browsers has improved significantly, but the large body of legacy documents which rely on the quirks of older browsers represents an obstacle for browser developers, who wish to improve their support for standardized HTML and CSS, but also wish to maintain with older, non-standardized pages. Additionally, many new web pages continue to be created in the older fashion, since the compatibility workarounds introduced by browser developers mean that an understanding of standardized methods is not strictly necessary.
To maintain compatibility with the greatest possible number of web pages, modern web browsers are generally developed with multiple rendering modes: in "standards mode" pages are rendered according to the HTML and CSS specifications, while in "quirks mode" attempts are made to emulate the behavior of older browsers. Some browsers rendering engine, or Internet Explorer 8 in strict mode, for example) also use an "almost standards" mode which attempts to compromise between the two, implementing one quirk for table cell sizing while otherwise conforming to the specifications

Quirks mode and strict mode are the two ’modes’ modern browsers can use to interpret your CSS.When Netscape 4 and IE 4 implemented CSS, their support did not match the W3C standard. Any websites rendered correctly in the various browsers, web developers had to implement CSS according to the wishes of these browsers. most websites used CSS in ways that didn’t quite match the specifications. when standards compliancy became important browser vendors faced a tough choice. Moving closer to the W3C specifications was the way to go, but if they would just change the CSS implementations to match the standards perfectly, many websites would break to a greater or lesser extent.

How to trigger quirks mode
Some doctypes or the inclusion of an declaration, trigger “quirks mode” or backwards compatible mode in IE 6. In that case, IE 6 acts like IE 5.5, and shares the same bugs, problems and behaviour as its elder brother.
In IE 7, an declaration no longer changes the rendering mode . Authors who want to keep all versions of IE up to IE 7 in quirks mode (without affecting other browsers) cannot rely on this anymore. However, inserting a comment before the doctype (but after the declaration) will still trigger quirks mode in IE 7, as in the example below.
1.
2.
3.
Quirks mode in IE 7 can also be triggered when coding HTML 4.01 documents. Inserting a comment before the DTD will trigger this backwards compatible mode in both IE 6 and IE 7.
1.
2.

Monday, June 30, 2008

Iframe Validating

I came across a solution for validating iframes in strict DTD. As iframe is a depreciated tag, still it works in html 4.01 ,xhtml1.0.But its better to use object in place of iframe.

[object] is for inserting any foreign object into XHTML documents. Since Iframes include HTML/XHTML documents, the MIME type for the document is “text/html” or “application/xhtml+xml”. We will use the first one because it is compatible with all browsers including Internet Explorer.

Let me show you by an example.

Note : ()= <>

(!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”)
(html xmlns=”http://www.w3.org/1999/xhtml” lang=”en” xml:lang=”en”)
(head)
(title)(/title)
(meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ /)
(/head)
(body)
(object style=”width:500px; height:200px” data=”http://www.google.com” type=”text/html” standby=”Google)(/object)
(/body)
(/html)

Let me briefly explain the terms which are used in the above snippet.

* classid - Defines a ClassID in the registry.
* data - The URL of the object (required).
* name - The name of the object if you are using it in JavaScript/VBScript or some other scripting language.
* standby - Text to display when loading.
* type - The MIME type of the object . Required.

When you run this example it is xhtml validated wheteher its transitional or strict.

Thursday, October 18, 2007

how to call div layer as slide left to right or right to left

After long time i am on my blog.

My first project with indian express

http://www.expressindia.com/gtest/final/expressindiascreen/index.html

i have done lots of new thing which is new for me

1. How to call div layer click on button as slide, when click on left button div layer move right to left as slide, when click on right button div layer move left to right as slide

2. button on off div show and collapse , when click on off button div show expend bottom , when click another off button than on button show off and div layer collapse and show other div layer.

3. click on link show diffrent div layer without javascript only through css

Tuesday, September 4, 2007

HOW TO USE DIFFERENT CSS FILE FOR MOZILLA AND IE EXPLORER

HOW TO USE DIFFERENT CSS FILE FOR MOZILLA AND IE EXPLORER


This script allows you to detect which browser your visitor is using, then loads up the correct cascading style sheet to suit. Change the name and paths, of the files ie.css (Internet Explorer) and nn.css (Netscape Navigator) to your own file names.

i am using here <> for []
This script needs to go inside the [HEAD] tags.

[SCRIPT LANGUAGE = "JavaScript"]
[!--
var browser = '';
var version = '';
var entrance = '';
var cond = '';
// BROWSER?
if (browser == ''){
if (navigator.appName.indexOf('Microsoft') != -1)
browser = 'IE'
else if (navigator.appName.indexOf('Netscape') != -1)
browser = 'Netscape'
else browser = 'IE';
}
if (version == ''){
version= navigator.appVersion;
paren = version.indexOf('(');
whole_version = navigator.appVersion.substring(0,paren-1);
version = parseInt(whole_version);
}
if (browser == 'IE' && version ]= 4) document.write('['+'link rel="stylesheet" href="ie.css" /]');
if (browser == 'Netscape' && version ]= 2.02) document.write('['+'link rel="stylesheet" href="nn.css" /]');
// --]
[/SCRIPT]

Thursday, August 30, 2007

The MVC (Model View Controller)

The MVC (Model View Controller)

introduction to MVC concepts as they are implemented in CakePHP.MVC (Model View Controller)

framework that inspired CakePHP: Ruby on Rails. Ruby on Rails is a web framework for the

programming language Ruby. It implements both Active Record and MVC.

The MVC paradigm is a way of breaking an application, or even just a piece of an

application's interface, into three parts: the model, the view, and the controller. MVC was

originally developed to map the traditional input, processing, output roles into the GUI

Input -> Processing -> Output

Controller -> Model -> View



The user input, the modeling of the external world, and the visual feedback to the user are separated and handled by model, view port and controller objects. The controller interprets mouse and keyboard inputs from the user and maps these user actions into commands that are sent to the model and/or view port to effect the appropriate change. The model manages one or more data elements, responds to queries about its state, and responds to instructions to change state. The view port manages a rectangular area of the display and is responsible for presenting data to the user through a combination of graphics and text.

What is CakePHP?

CakePHP :CakePHP is a free open-source rapid development framework for PHP: a structure of libraries, classes and run-time infrastructure for programmers creating web applications originally inspired by the Ruby on Rails framework.

Why CakePHP?

CakePHP has several features that make it great choice as a framework for developing applications swiftly and with the least amount of hassle:

* Useful core features (for access control lists, AJAX integration, etc.)

* Request dispatcher with good looking, custom URLs

* Compatibility with PHP4 and PHP5

* Works from any website subdirectory, with little to no Apache configuration

* Supplies integrated CRUD for database interaction and simplified queries (including scaffolding)

* Fast and flexible templating (PHP syntax, with helpers)

Sunday, August 12, 2007

How to diseble mouse right click for website image

How to diseble mouse right click for website image

Use this code inside of head tag your html file, I am using here <> fir []
please (is lessthan)=< use

[script language="JavaScript1.2"]

/*
Disable right click script II (on images)-

*/

var clickmessage="Right click disabled on images!"

function disableclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
alert(clickmessage);
return false;
}
}
}
else if (document.layers) {
if (e.which == 3) {
alert(clickmessage);
return false;
}
}
else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
alert(clickmessage)
return false
}
}
}

function associateimages(){
for(i=0;i(is lessthan)document.images.length;i++)
document.images[i].onmousedown=disableclick;
}

if (document.all)
document.onmousedown=disableclick
else if (document.getElementById)
document.onmouseup=disableclick
else if (document.layers)
associateimages()
[/script]

Sunday, August 5, 2007

Active Record

Active Record
Active Record is the ORM layer supplied with Rails. It closely follows the standard ORM model: tables map to classes, rows to objects, and columns to object attributes. It differs from most other ORM libraries in the way it is configured. By relying on convention and starting with sensible defaults, Active Record minimizes the amount of configuration that developers perform. To illustrate this, here’s a program that uses Active Record to wrap
our orders table.

require 'active_record'
class Order < ActiveRecord::Base
end

order = Order.find(1)
order.discount = 0.5
order.save

This code uses the new Order class to fetch the order with an id of 1 and
modify the discount. (We’ve omitted the code that creates a database connection
for now.) Active Record relieves us of the hassles of dealing with
the underlying database, leaving us free to work on business logic.
But Active Record does more than that. As you’ll see when we develop our
shopping cart application, starting on page 43, Active Record integrates
seamlessly with the rest of the Rails framework. If a web form contains
data related to a business object, Active Record can extract it into our
model. Active Record supports sophisticated validation of model data, and
if the form data fails validations, the Rails views can extract and format
errors with just a single line of code.
Active Record is the solid model foundation of the Rails MVC architecture.

Object/Relational Mapping

Object/Relational Mapping

ORM libraries map database tables to classes. If a database has a table
called orders, our program will have a class named Order. Rows in this
table correspond to objects of the class—a particular order is represented as an object of class Order. Within that object, attributes are used to get and set the individual columns. Our Order object has methods to get and set the amount, the sales tax, and so on. In addition, the Rails classes that wrap our database tables provide a set of class-level methods that perform table-level operations. For example,
we might need to find the order with a particular id. This is implemented
as a class method that returns the corresponding Order object. In Ruby class method

order = Order.find(1) puts
puts "Order #{order.customer_id}, amount=#{order.amount}"
Sometimes these class-level methods return collections of objects.
iterating
Order.find(:all, :conditions => "name='dave'") do |order|
puts order.amount
end

Finally, the objects corresponding to individual rows in a table have methods
that operate on that row. Probably the most widely used is save( ), the
operation that saves the row back to the database.
Order.find(:all, :conditions => "name='dave'") do |order|
order.discount = 0.5
order.save
end

So an ORM layer maps tables to classes, rows to objects, and columns to
attributes of those objects. Class methods are used to perform table-level
operations, and instance methods perform operations on the individual
rows.
In a typical ORM library, you supply configuration data to specify the mappings
between things in the database and things in the program. Programmers
using these ORM tools often find themselves creating and maintaining
a boatload of XML configuration files.

Active Record: Rails Model Support & Database-centric Programming

Active Record: Rails Model Support
In general, we’ll want our web applications to keep their information in a
relational database. Order entry systems will store orders, line items, and
customer details in database tables. Even applications that normally use
unstructured text, such as weblogs and news sites, often use databases
as their backend data store.
Although it might not be immediately apparent from the SQL you use to
access them, relational databases are actually designed around mathematical
set theory. While this is good from a conceptual point of view,
it makes it difficult to combine relational databases with object-oriented
programming languages. Objects are all about data and operations, and
databases are all about sets of values. Things that are easy to express
in relational terms are sometimes difficult to code in an OO system. The
reverse is also true.
Over time, folks have worked out ways of reconciling the relational and
OO views of their corporate data. Let’s look at two different approaches.
One organizes your program around the database; the other organizes the
database around your program.

Database-centric Programming

The first folks who coded against relational databases programmed in procedural
languages such as C and COBOL. These folks typically embedded
SQL2 directly into their code, either as strings or by using a preprocessor
that converted SQL in their source into lower-level calls to the database
engine.
The integration meant that it became natural to intertwine the database
logic with the overall application logic. A developer who wanted to scan
through orders and update the sales tax in each order might write something
exceedingly ugly, such as
EXEC SQL BEGIN DECLARE SECTION;
int id;
float amount;
EXEC SQL END DECLARE SECTION;
EXEC SQL DECLARE c1 AS CURSOR FOR
select id, amount from orders;
while (1) {
float tax;

EXEC SQL WHENEVER NOT FOUND DO break;
EXEC SQL FETCH c1 INTO :id, :amount;
tax = calc_sales_tax(amount)
EXEC SQL UPDATE orders set tax = :tax where id = :id;
}
EXEC SQL CLOSE c1;
EXEC SQL COMMIT WORK;
Scary stuff, eh? Don’t worry. We won’t be doing any of this, even though
this style of programming is common in scripting languages such as Perl
and PHP. It’s also available in Ruby. For example, we could use Ruby’s
DBI library to produce similar-looking code. (This example, like the last,
has no error checking.)
def update_sales_tax
update = @db.prepare("update orders set tax=? where id=?")
@db.select_all("select id, amount from orders") do |id, amount|
tax = calc_sales_tax(amount)
update.execute(tax, id)
end
end
This approach is concise and straightforward and indeed is widely used.
It seems like an ideal solution for small applications. However, there is
a problem. Intermixing business logic and database access like this can
make it hard to maintain and extend the applications in the future. And
you still need to know SQL just to get started on your application.