Posted by: viralsarvaiya on: October 29, 2009
This will find X and Y coordinates of the mouse where the mouse moves in browser.
<html>
<head>
<title>Get Mouse Coordinates</title>
<script language=”javascript”>
var divObj;
document.onmousemove=getMouseCoordinates;
function getMouseCoordinates(event)
{
ev = event || window.event;
divObj.innerHTML = “Mouse X:”+ev.pageX + ” Mouse Y:”+ev.pageY;
}
function loadDiv()
{
divObj = document.getElementById(“mouseCoord”);
}
</script>
</head>
<body onLoad=”loadDiv()”>
<div id=”mouseCoord”>Mouse Coordinates position will be displayed here.
</div>
</body>
</html>
Posted by: viralsarvaiya on: October 28, 2009
I have one CheckBoxList control that binds values at runtime from the database, and when I click on a button from the page, I want to get the values (Database Primary Key) from the CheckBoxList, but for the checked checkboxes only.
Here is the code, what I have achieved so far. This code works fine with [...]
Posted by: viralsarvaiya on: October 27, 2009
take a element of Div
<div id=”contentmsg” style=”position: absolute; right:25%; width: 100px; height:100px;visibility: hidden;”>
<img src=”images/loading.gif” width=”50px” height=”50px” />
</div>
suppose we have a dropdown and according to onchange() event this div is visible or hide,
<asp:DropDownList ID=”ddlparavalue” runat=”server”></asp:DropDownList>
in the server side bind the dropdownlist dynamically and add the attribultes as below
ddlparavalue.Attributes.Add(“onchange”, “javascript:void HideOrVisibleDDL();”)
in the head of the html section [...]
Posted by: viralsarvaiya on: October 20, 2009
Follow these steps to enable script debugging in VS.NET
Tools->Internet Options…->Advanced->Disable Script Debugging [Un-check]
When you’ve enabled Script Debugging, then in the IE go to, View->Script Debugger->Open
Once you clicked Open, the page reloads and activates the script debugger, you can set break-point and do F10 & F11.
Alternately, you can put a line like this in the java-script code [...]
Posted by: viralsarvaiya on: August 11, 2009
Here i demonstrate, how to set maximum length of the textarea or multiline textbox with javascript.
copy this code in the head section of the page.
<script language=”javascript” type=”text/javascript”>
function CheckFieldLength1(fn, mc) {
var len = fn.value.length;
if (len > mc) {
fn.value = fn.value.substring(0, mc);
len = mc;
}
document.getElementById(“charcount”).innerHTML = len;
document.getElementById(“remaining”).innerHTML = mc – len;
}
</script>
now in the body section,
<asp:TextBox ID=”txtDesc” runat=”server” Width=”500″ [...]
Posted by: viralsarvaiya on: July 11, 2009
The whole idea of the tutorial is to dynamically validate the data and display the results when the user is typing the same. The advantage of this approach is that it allows the user to correct its mistake first and the move to the next item
The article will cover the following aspects of data validation
1. [...]
Posted by: viralsarvaiya on: July 11, 2009
<script type = “text/javascript”>
var defaultText = “Enter your text here”;
function WaterMark(txt, evt)
{
if(txt.value.length == 0 && evt.type == “blur”)
{
txt.style.color = “gray”;
txt.value = defaultText;
}
if(txt.value == defaultText && evt.type == “focus”)
{
txt.style.color = “black”;
txt.value=””;
}
}
</script>
The script will be called on onblur and onfocus events of the textbox. The script simply does the following two checks
1. If the textbox is empty [...]
Posted by: viralsarvaiya on: July 1, 2009
<script language=”javascript”>
var sLink = window.location.href.toLowerCase(); ;
if (sLink.indexOf(“http://”) > -1) {
if (sLink.indexOf(“www.”) == -1) {
sLink = sLink.replace(“http://”, “http://www.”);
window.location.href = sLink;
}
}
</script>
Put this script in head tag of your page
Posted by: viralsarvaiya on: June 11, 2009
to check the java script is enable or disable, it is too easy use
<noscript>
<meta http-equiv=’refresh’ content=’0;url=http://yoursite.com/yourdirectory/yourfile.htm’/>
</noscript>
here, if the java script is disable then it redirect to you site’s error page.if u want to write any thing instead of redirect then you can write any HTML tag with you message in .
Posted by: viralsarvaiya on: June 8, 2009
Make one javascript file named “dm.js” and put below code into it.
********************************************
var omitformtags=["input", "textarea", "select"]
omitformtags=omitformtags.join(“|”)
function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}
function reEnable(){
return true
}
if (typeof document.onselectstart!=”undefined”)
document.onselectstart=new Function (“return false”)
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
var message = “”;
function clickIE() { if (document.all) { (message); return false; } }
function clickNS(e) {
if
(document.layers || (document.getElementById && !document.all)) {
if (e.which == 2 || e.which == 3) { (message); return [...]
Recent Comments