|
|
JavaScript/JScript
javascript is the most powerful browser scripts. It let us create RIA without flash, silverlight. there are a lot of Ajax framework today. In here you will find some javascript hacks, tips, sample and working copy of javascript codes.
This DateDiff function is used to calculate the date difference in months between 2 date.
How to use the DateDiff function:
var diff = DateDiff(fromDate, toDate)
document.write(diff.Years + ' years ' + diff.Months + ' months ' + diff.Days + ' days');
Source code:
var monthDay = new Array(31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
f... continue reading »
Javascript function used to format number in currency format, for example: format 1000.25 as $1,000.25
function formatCurrency(num)
{
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num)) num = "0";
sign = (num == (num = Math.abs(num)));
... continue reading »
Using JavaScript to automatically adjust the height of iFrames on your page(s)
This javascript was tested on IE and FF, It works fine.
1. Html Code for IFrame
<iframe id="frameContent" name="frameContent" onload="return IframeOnload('frameContent');" class="adm_iframe" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></if... continue reading »
How to fix GridView's Header row while scrolling?
I googled a lot, find some are using expression wich only work for IE and the performance is bad. Some are using TBody scroll, which also does not work well in all browsers. Also I found a JQuery plugin which is working very well in their demo page, but does not work for my case. Below i... continue reading »
How to call server function using JavaScript, or How to trigger button's click event by using JavaScript. For example: You have a linkbutton in your page, and the linkbutton's click event will do something.
<asp:LinkButton ID="lbtnGetDetails" runat="server" style="display:'none';" OnClick="lbtnGetDetails_Clicked" />
protected void lbtnGetDe... continue reading »
I have added the DNN module and Skin Object for Google custom search, with Adsense support. The module and skin object are using JavaScript to trigger the search function, No form and Postback required, I am using this skin object replace the dnn core search skin object. The reason is that I only need the google search. I have disabled th... continue reading »
This article will cover how to JavaScript to handle browser events. Such as: Add/Attach event, Remove Event, onpropertychange, block/cancel event, add event to window.onload and how to get the target element of the event. continue reading »
The hover selector is wonderful css technique that can add style to an element as well as improve usability, The problem with this technique is it works in all browsers except IE6, of course. IE6 only supports the :hover pseudo-class on anchor () tags. So how can we fix it? I have googled a lot and finally found a excellent solution for this: to us... continue reading »
If you are not using the JavaScript library, like: JQuery, ASP.NET Ajax, ExtJs etc, it is better for you to have these javascript function as your own Javascript Library.
1. addEvent
function addEvent(elm, evType, fn, useCapture) {
if (elm.addEventListener) {
elm.addEventListene... continue reading »
Why we need to preload css hover images? It is for the userability. Why we need to preload css hover images by Javascript? It is easy to implement and maintenance. below is the sample css class for a image button. .button { background-image: url(../images/button.jpg); } .button:hover { backgro... continue reading »
|
|