Tuesday, November 3, 2009
Monday, July 13, 2009
Tips for Cross Browser Compatibility
1. All HTML controls in the page should have an ID attribute.
Example: <.... type="”text”" name="”txtname”" id="”txtname”">
2. Always use fixed width and height rather than percentages.
Example:
Fixed width: <.... width="”600”">......< /table>
Percentages: <.... width="”70%”">......< /table>
3. All the elements in the page should be bound in a proper html layout.
Example:
Correct: <..><..><..><..>< id="”test”">< /span>< /td>< /tr>< /table>< /body>
Wrong: <..><..><..><..>< /td>< /tr>< /table>< id="”test”">< /span>< /body>
4. Modal windows does not work properly in firefox. Use normal pop up windows instead.
Example:
window.open(....) works well in all conditions. ShowModaldialog does not work properly.
5. parent.dialogArguments does not work in firefox. Use parent.opener instead.
Example:
var strVals = parent.opener ? parent.opener : parent.dialogArguments;
strVals.callfunction()
6. While accessing html elements in javascript,
do not use document.forms[0].......Use document.getElementById(...)
do not use document.all(....). Always use document.getElementById(...)
7. window.event does not work in firefox. Instead we should pass the event to the calling javascript function and access using event.target.
Example:
< type="image" src="images/SFReset.gif" id="img2" name="img2" onclick="”ResetFields(event)”">
function ResetFields(e)
{
if (window.event)
var xButton = window.event.srcElement;
else
var xButton = e.target.name;
}
8. Automatic reload of the page does not work in some situations. Use Ajax in such cases.
9. SQL Reporting services reports frame width is height is shrinked in firefox.
To increase the frame height and width,
Go to Program Files → Microsoft SQL Server → MSSQL3 (Differs for different versions of sql server. Purpose is to locate Reporting Services folder) → Reporting Services → Report Server → Pages
Open ReportViewer.aspx
Add width and height attributes to the custom report viewer control.
Example: RS:ReportViewerHost width="1000px" height="860px" id="ReportViewerControl" runat="server">
10. semicolon in “nbsp;” is a must.
11. In javascript, use "getFullYear" whereever you use "getYear".
Tuesday, December 2, 2008
onkeypress not fired for Backspace and Delete
Here is a new thing that i have come across and wanted to share.
Scenario:
I was just experimenting to show the character count dynamically when a user types text in textarea. I have called a javascript function in onkeypress event of the textarea to calculate the count and put that in a html div element using innerHTML.
Observation:
onkeypress event does not fire for Back space and Delete keys in the keyboard.
Solution:
Use both onkeypress and onkeyup events and call the same function.
Saturday, October 4, 2008
Open a url in Kiosk/Full Screen mode
We can implement this by making configuration changes in window.open method of javascript.
Here is the sample logic:
window.open("sample.html","newwindow","fullscreen")
Monday, September 15, 2008
Browser detection in ASP
Request.ServerVariables("HTTP_USER_AGENT") will result in the following:
For IE:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
For Firefox:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
Based on above, we can write below logic.
varBrowser= Request.ServerVariables("HTTP_USER_AGENT")
If InStr(varBrowser, "MSIE") > 0 Then
BrowserType = "IE"
Elseif InStr(varBrowser, "Firefox") > 0 Then
BrowserType = "FireFox"
End if
Saturday, September 13, 2008
Recordset GetString() method
This method can be used to fill HTML tables in ASP files.
You can find the details of the method in the below link:
http://www.w3schools.com/ADO/met_rs_getstring.asp
Saturday, June 14, 2008
Generate HTML dynamically in javascript
Suppose you want a textbox control to be added each time in an on click event of a hyper link,
Onclick javascript function:
You can use this logic according to your requirements.

