How to set the x,y position of panel same for all browser

Posted by Tamilselvantms under ASP.NET on 3/28/2013 | Points: 10 | Views : 1681 | Status : [Member] | Replies : 2
Dear All,
I developed one web application that has one panel, in that i am capturing
x,y coordinates. If i run in Mozilla Firefox, its starts from 0. If i run in Internet Explorer, the position and coordinates getting change. I need to set the same x,y coordinates for all the browsers. Kindly give me the solution for this problem. I attached the code below for further details.

<script type='text/javascript'>

function getMouseXY(e) {
document.getElementById('x').value = e.pageX || event.clientX;
document.getElementById('y').value = e.pageY || event.clientY;

if (document.getElementById('x').value >= 558 && document.getElementById('x').value < 794 && document.getElementById('y').value >= 272 && document.getElementById('y').value < 285) {
document.getElementById("name").style.backgroundColor = "#F7D5D5";
document.getElementById('<%=name.ClientID%>').disabled = true;
}
}
</script>
<form>
<div>
<asp:Panel ID="Panel1" BorderWidth="2" BorderColor="black" runat="server" Width="500px" Height="615px" onmousemove='return getMouseXY(event);'>
</asp:Panel>
</div>
</form>

by
Tamil



Responses

Posted by: Mohansubramanian on: 3/28/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

set the hight, width , coordinates of the page in % wise instead of setting in pixel terms. Because the screen resoultion would be vary from system to system. Sometimes also in browsers.

Regards,
Mohan Subramanian
powerofmicrosoft.blogspot.in

Regards,
Mohan Subramanian
http://mohanks.com

Tamilselvantms, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tamilselvantms on: 3/29/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,
Yesterday i got this code below:

<html>
<body>

<h3>Thenatureoftheunderlyingelectroniccomponentsdidn'tchangebetweenthesecomputersandmoderncomputersweknowoftoday,butwhatdidchangewasthenumberofcircuitsthatcouldbeputontoasinglemicrochip.Intel'sco-founderGordonMoorepredictedthedoublingofthenumberoftransistoronasinglechipeverytwoyears,whichbecameknownas"Moore'sLaw",andthistrendhasroughlyheldforover30yearsthankstoadvancingmanufacturingprocessesandmicroprocessordesigns.</h3>
<form name="Show">
<table>
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td>
<input type="text"name="MouseX"value="0"size="4">X<br>
<input type="text"name="MouseY"value="0"size="4">Y<br>
</td>
</tr>


</table>
</form>


<script language="JavaScript1.2">



var IE=document.all?true:false

if(!IE)document.captureEvents(Event.MOUSEMOVE)

document.onmousemove=getMouseXY;

var tempX=0
var tempY=0
function getMouseXY(e){
if(IE){
tempX=event.clientX+document.body.scrollLeft
tempY=event.clientY+document.body.scrollTop
}else{
tempX=e.pageX
tempY=e.pageY
}

if(tempX < 0){tempX=0}
if(tempY < 0){tempY=0}
document.Show.MouseX.value=tempX
document.Show.MouseY.value=tempY
returntrue
}

</script>
</body>
</html>

Note: Just run in IE.

This is working in HTML only, not in aspx. how to work in aspx. Kindly help me.

by
Tamil

Tamilselvantms, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response