http://hack2wwworld.blogspot.in/2011/06/web-application-security-hidden-field.html
Wednesday, 12 December 2012
Tuesday, 6 November 2012
"Use same function by using element ID":Pass id as an argument to use function for different events on different elements
we can also use a common function that binds to different event associated with different elements and we only pass id and access the function by identifying id in function argument like this
function ValidateForAllValue(id )
{
var str=""
$("select#"+id+" option:selected").each(function ( )
{
if($(this).val() =="Defined" )
{
str=str+$(this).val();
}
if(str=="Defined" && $(this).val() != "Defined")
{
alert("Invalid selection: option 'All' can not be selected with any other option");
$(".AllClass").val([])
return false;
}
if ($(this).val() == "None")
{
$(".AllClass").val([]);
alert("Select some valid option");
}
});
};
Here this function displays alert for the element if user select "All" along with other option.Therefore we can call this function for any select list by passing on onclick attribute like this:
<select onclick="ValidateForAllValue(this.id)">
$(this) always works on iteration
You cannot access an element with $(this) at event binding like this:
<select onclick="fun()">
....
fun()
{
$(this).each(function ( )
{
.....
........
Reason : It works in iteration to refer to the element
$("select#"+id+" option:selected").each(function ( )
{
if($(this).val() =="Defined" )
{
str=str+$(this).val();
.............................
or you can also use that element at finction calling like this.....
<select id="xyz" onclick="fun(this.id)">
<select onclick="fun()">
....
fun()
{
$(this).each(function ( )
{
.....
........
Reason : It works in iteration to refer to the element
$("select#"+id+" option:selected").each(function ( )
{
if($(this).val() =="Defined" )
{
str=str+$(this).val();
.............................
or you can also use that element at finction calling like this.....
<select id="xyz" onclick="fun(this.id)">
Tuesday, 16 October 2012
To write a complete HTML structure in a new window
function ShowDatePopUp()
{
alert("hello");
newwindow= window.open('','name','location=1,status=1,scrollbars=1,height=300,width=300');
newwindow.moveTo(0, 0);
newwindow.document.write('<html><head><title>');
newwindow.document.write('Date Window');
newwindow.document.write('</title></head>');
newwindow.document.write('<BODY><form>');
newwindow.document.write('<label for='TxtDate'>Enter Date </label>');
newwindow.document.write('<input type='text' id='DateId' name='TxtDate'/>');
newwindow.document.write('<input type='submit' value='Submit' class='SubmitButton'/>');
newwindow.document.write('</form></BODY></html>');
newwindow.document.close();
}
function ShowDateRangePopUp()
{{
alert("hello");
newwindow= window.open('','name','location=1,status=1,scrollbars=1,height=300,width=300');
newwindow.moveTo(0, 0);
newwindow.document.write('<html><head><title>');
newwindow.document.write('Date Window');
newwindow.document.write('</title></head>');
newwindow.document.write('<BODY><form>');
newwindow.document.write('<label for='TxtDate'>Enter Date </label>');
newwindow.document.write('<input type='text' id='DateId' name='TxtDate'/>');
newwindow.document.write('<input type='submit' value='Submit' class='SubmitButton'/>');
newwindow.document.write('</form></BODY></html>');
newwindow.document.close();
}}
Friday, 12 October 2012
Empty cells in a table
One day i worked on a table that fetches some record from database.But the empty cells were coming without border like that:(in internet explorer)
actually the table tag is like that
<table border="1">
To troubleshoot problem my TL suggested to include attribute/values for table tag as
rules="all" frame="box"
<table border="1" rules="all" frame="box">
my problem was solved (:)
Rules attribute of table tag--he
//Display only the borders between the rows:
<table rules="rows">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
//Display only the borders between the coloumns:
<table rules="cols">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
<table rules="all">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
</body>
</html>
frame="box "Display only the outside borders of a table:
Note: to encounter the above problem either give
<table border="1" rules="all" frame="box">
or
<table border="1" frame="box">
actually the table tag is like that
<table border="1">
To troubleshoot problem my TL suggested to include attribute/values for table tag as
rules="all" frame="box"
<table border="1" rules="all" frame="box">
my problem was solved (:)
Rules attribute of table tag--he
rules
attribute allows you to set borders (also called rules, surprise, surprise!) inside the table
at the boundaries between cells//Display only the borders between the rows:
<table rules="rows">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
Table with rules="rows":
Month | Savings |
---|---|
January | $100 |
//Display only the borders between the coloumns:
<table rules="cols">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
Table with rules="cols":
Month | Savings |
---|---|
January | $100 |
<table rules="all">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
</body>
</html>
Table with rules="all":
Month | Savings |
---|---|
January | $100 |
frame="box "Display only the outside borders of a table:
Note: to encounter the above problem either give
<table border="1" rules="all" frame="box">
or
<table border="1" frame="box">
Monday, 1 October 2012
Tp calculate size of element
count = 0;
$("#SelectClientForExport option").each(function ( )
{
count++;
});
alert(count);
or either use
alert( $("#SelectClientForExport option").size());
$("#SelectClientForExport option").each(function ( )
{
count++;
});
alert(count);
or either use
alert( $("#SelectClientForExport option").size());
Thursday, 27 September 2012
Value,text and index (intersting way to handle form elements)
To reset fields we can use: either
val()
text( )
index( )
Generally we usually access elementseither by following selector
1.using id
2.using group selector like all select elements
3. using class name
but we can also access element with the help of text,index and value
val()
text( )
index( )
Generally we usually access elementseither by following selector
1.using id
2.using group selector like all select elements
3. using class name
but we can also access element with the help of text,index and value
Monday, 24 September 2012
Setting all value in Multiselector
Usually Multiselector doesn't have "all" option value..If it happens then then it's better to set value as "All" if <select> tag is defined in one form page and we render the value to some another page or multiple pages.If we defined it in same page and get on same page then we must have to define the value at declaration time.
Now if we get the value from "Select tag" then the value we are getting like this:
"val1 val2 val3"
and this single must be tokenised to iereate over multiple option values by two approach:
1.Using blank space " "
2.similar string patern.
First approach: (Best approach)
It is safe to use first approach if option string values doesn't have multiple sapces.Therefore try to avoid spaces in option values at definition time till it is not compulsary ( by normalising/trimming/removing spaces see difference in another blog for all three terms ) so that we can easily tokenized by using this approach since after each value there is a space val1 val2 val3 etc.
Second approach:
If it is complulsary to havaing spaces in string and string have some business pattern like (exporting each pdf or xml has an extension .pdf or .xml) therefore we can tokenize over each value as:
for ex- let $All := "0001012-0000002-KOMMUNEKREDIT.xml 0001012-0000003 KOMMUNE KREDIT.xml"
for $Each at $pos in fn:tokenize($All,".xml")[1 to fn:last()-1]
let $EachBatch := fn:normalize-space(fn:concat($Each,".xml"))
return $EachBatch
and then we also need to concat the value over which each string is tokenised.Here we run the loop to the second last element otherwise result would come as: >
0001012-0000002-KOMMUNEKREDIT.xml
0001012-0000003-KOMMUNE KREDIT.xml
.xml
there fore we skip last element.
Third Approach (Only used in following situation)
But what happens if we have compulsion to have spaces in option values and string doesn't have patterns then we have to append some tag identofire with each option value at declaration time or rendered time to differntiate multiple values.
Now if we get the value from "Select tag" then the value we are getting like this:
"val1 val2 val3"
and this single must be tokenised to iereate over multiple option values by two approach:
1.Using blank space " "
2.similar string patern.
First approach: (Best approach)
It is safe to use first approach if option string values doesn't have multiple sapces.Therefore try to avoid spaces in option values at definition time till it is not compulsary ( by normalising/trimming/removing spaces see difference in another blog for all three terms ) so that we can easily tokenized by using this approach since after each value there is a space val1 val2 val3 etc.
Second approach:
If it is complulsary to havaing spaces in string and string have some business pattern like (exporting each pdf or xml has an extension .pdf or .xml) therefore we can tokenize over each value as:
for ex- let $All := "0001012-0000002-KOMMUNEKREDIT.xml 0001012-0000003 KOMMUNE KREDIT.xml"
for $Each at $pos in fn:tokenize($All,".xml")[1 to fn:last()-1]
let $EachBatch := fn:normalize-space(fn:concat($Each,".xml"))
return $EachBatch
and then we also need to concat the value over which each string is tokenised.Here we run the loop to the second last element otherwise result would come as: >
0001012-0000002-KOMMUNEKREDIT.xml
0001012-0000003-KOMMUNE KREDIT.xml
.xml
there fore we skip last element.
Third Approach (Only used in following situation)
But what happens if we have compulsion to have spaces in option values and string doesn't have patterns then we have to append some tag identofire with each option value at declaration time or rendered time to differntiate multiple values.
Tuesday, 24 July 2012
Is your hide div is exist in body before you show?
Today I worked on a task in which a hide div has to be display on onclick event binding.But i was irritated when the div is not showing through show().
Reason: div to be show is not placed in body (because of some if condition or may be it placed in some function that is not called inside body)
Reason: div to be show is not placed in body (because of some if condition or may be it placed in some function that is not called inside body)
Sunday, 22 July 2012
difference in empty() and remove()
- Empty will remove all the contents of the selection.
- Remove will remove the selection and its contents.
Consider:
<div>
<p><strong>foo</strong></p>
</div>
$('p').empty(); // --> "<div><p></p></div>"
// whereas,
$('p').remove(); // --> "<div></div>"
Friday, 20 July 2012
Applying validation using Javascript on event binding always use button rather than submit
Reason : Since while checking negative condition on validation we must restrict the form to load or submit.To stop loading of form we can't use submit button because it loads form atleast once
Thursday, 19 July 2012
return false exit from function
We thought return false only stops the form to submit ..but it is not true actually it stops the function to return the value that function wants to return and also exit the program control from the function (Its a programming principle that when a function return false then control exit the function).
Wednesday, 18 July 2012
Calling two function on single event
We can call multiple functions on a single event such as onclick,onsubmit etc by seperating with semicolon sign ;....like this
<a href="..." onclick="fun1();fun2();">
Alert: -1.Make sure the first function not submit the form otherwise second function will not execute and
2. same thing happens when first function have explicit return statement that time also second function may not execute.
<a href="..." onclick="fun1();fun2();">
Alert: -1.Make sure the first function not submit the form otherwise second function will not execute and
2. same thing happens when first function have explicit return statement that time also second function may not execute.
Thursday, 5 July 2012
Difference in onclick and onClick()
Event attributes in HTML are not case sensitive, so
onclick
, onClick
and ONCLICK
all work. It is common practice to write attributes in lowercase: onclick
. note that javascript itself is case sensitive, so if you write document.getElementById("...").onclick = ...
, then it must be all lowercase.
Wednesday, 4 July 2012
Dont write explicitly javascript:Calling a return type js function on event binding
Don't write javascript while returning a function on some event binding.
Ex-<input type="button" value="Submit" onclick="return javascript:ConfirmClientForRelocation()"/>
Here google chrome is not catch this so use instead
Ex-<input type="button" value="Submit" onclick="return ConfirmClientForRelocation()"/>
Tuesday, 26 June 2012
html5test.com
your browser scores
402
AND 13 BONUS POINTS
out of a total of 500 points
Parsing rules | +2 bonus points11 |
---|---|
<!DOCTYPE html> triggers standards mode | Yes ✔ |
HTML5 tokenizer | Yes ✔ |
HTML5 tree building | Yes ✔ |
HTML5 defines rules for embedding SVG and MathML inside a regular HTML document. Support for SVG and MathML is not required though, so bonus points are awarded if your browser supports embedding these two technologies. | |
SVG in text/html | Yes ✔ |
MathML in text/html | Yes ✔ |
Canvas | 20 |
---|---|
canvas element | Yes ✔ |
2D context | Yes ✔ |
Text | Yes ✔ |
Video | +6 bonus points21/31 |
---|---|
video element | Yes ✔ |
Subtitle support | No ✘ |
Poster image support | Yes ✔ |
The following tests go beyond the requirements of the HTML5 specification and are not counted towards the total score. If browser support for one or more video codecs is detected, two bonus points are awarded for each codec. | |
MPEG-4 support | No ✘ |
H.264 support | Yes ✔ |
Ogg Theora support | Yes ✔ |
WebM support | Yes ✔ |
Audio | +5 bonus points20 |
---|---|
audio element | Yes ✔ |
The following tests go beyond the requirements of the HTML5 specification and are not counted towards the total score. If browser support for one or more audio codecs is detected, one bonus point is awarded for each codec. | |
PCM audio support | Yes ✔ |
AAC support | Yes ✔ |
MP3 support | Yes ✔ |
Ogg Vorbis support | Yes ✔ |
WebM support | Yes ✔ |
Elements | 25/30 |
---|---|
Embedding custom non-visible data | Yes ✔ |
New or modified elements | |
Section elements | Yes ✔ |
Grouping content elements | Yes ✔ |
Text-level semantic elements | Partial ○ |
Interactive elements | Partial ○ |
Global attributes or methods | |
hidden attribute | Yes ✔ |
Dynamic markup insertion | Yes ✔ |
Forms | 74/108 |
---|---|
Field types | |
input type=text | Yes ✔ |
input type=search | Yes ✔ |
input type=tel | Yes ✔ |
input type=url | Yes ✔ |
input type=email | Yes ✔ |
input type=datetime | No ✘ |
input type=date | No ✘ |
input type=month | No ✘ |
input type=week | No ✘ |
input type=time | No ✘ |
input type=datetime-local | No ✘ |
input type=number | Yes ✔ |
input type=range | Yes ✔ |
input type=color | No ✘ |
input type=checkbox | Yes ✔ |
input type=image | Partial ○ |
input type=file | Yes ✔ |
textarea | Yes ✔ |
select | Yes ✔ |
fieldset | Partial ○ |
datalist | No ✘ |
keygen | Yes ✔ |
output | Yes ✔ |
progress | Yes ✔ |
meter | Yes ✔ |
Fields | |
Field validation | Yes ✔ |
Association of controls and forms | Yes ✔ |
Other attributes | Yes ✔ |
CSS selectors | Yes ✔ |
Events | Yes ✔ |
Forms | |
Form validation | Yes ✔ |
User interaction | 37 |
---|---|
Drag and drop | |
Attributes | Yes ✔ |
Events | Yes ✔ |
HTML editing | |
Editing elements | Yes ✔ |
Editing documents | Yes ✔ |
APIs | Yes ✔ |
Spellcheck | |
spellcheck attribute | Yes ✔ |
History and navigation | 5 |
---|---|
Session history | Yes ✔ |
Microdata | 0/15 |
---|---|
Microdata | No ✘ |
Web applications | 18/20 |
---|---|
Application Cache | Yes ✔ |
Custom scheme handlers | Yes ✔ |
Custom content handlers | No ✘ |
Custom search providers | Yes ✔ |
Security | 5/15 |
---|---|
Sandboxed iframe | Yes ✔ |
Seamless iframe | No ✘ |
iframe with inline contents | No ✘ |
Various | 4/6 |
---|---|
Scoped style element | No ✘ |
Asyncronous script execution | Yes ✔ |
Runtime script error reporting | Yes ✔ |
Base64 encoding and decoding | Yes ✔ |
related specifications
Location and Orientation | 20 |
---|---|
Geolocation | Yes ✔ |
Device Orientation | Yes ✔ |
WebGL | 25 |
---|---|
3D context | Yes ✔ |
Native binary data | Yes ✔ |
Communication | 37 |
---|---|
Cross-document messaging | Yes ✔ |
Server-Sent Events | Yes ✔ |
XMLHttpRequest Level 2 | Yes ✔ |
WebSocket | Yes ✔ |
Files | 20 |
---|---|
FileReader API | Yes ✔ |
FileSystem API | Yes ✔ |
Storage | 20 |
---|---|
Session Storage | Yes ✔ |
Local Storage | Yes ✔ |
IndexedDB | Yes ✔ |
The Web SQL Database specification is no longer being updated and has been replaced by IndexedDB. Because at least 3 vendors have shipped implementations of this specification we still include it in this test. | |
Web SQL Database | Yes ✔ |
Workers | 15 |
---|---|
Web Workers | Yes ✔ |
Shared Workers | Yes ✔ |
Local multimedia | 0/20 |
---|---|
Access the webcam | No ✘ |
Notifications | 10 |
---|---|
Web Notifications | Yes ✔ |
Other | 7 |
---|---|
Page Visibility | Yes ✔ |
Text selection | Yes ✔ |
Scroll into view | Yes ✔ |
experimental
Audio | 4 |
---|---|
Web Audio API | Yes ✔ |
Video and Animation | 4 |
---|---|
Full screen support | Yes ✔ |
window.requestAnimationFrame | Yes ✔ |
id: 1340703277922_c2df
Subscribe to:
Posts (Atom)