Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

jscript

  Asked By: Diem    Date: Jan 03    Category: Asp.net    Views: 531
  

Low down, image in page, want to cut a diagonal and post co-ords to server.
ISMAP is no good as it only posts a point. I want to cut a rectangle and zoom.

Soz to bug you again and some info for your memory banks.
I know its a minor point but I have tried to sort it .... at least for IE5+
If you can't be bothered then thats ok as it is such a minor point.

The functions you gave me work fine all the way up to the document.body ...
there we run into a problem as described.
Recap .. if the body has been set with a style tag, or if it has been given
assigned a class with a border width then it breaks your code
Now the function I sent you before was this ... for the style top


var ie5 = document.all != null && document.getElementsByTagName != null;
function getTopPos(el) {
if (ie5) {
if (el.currentStyle.top == "auto")
return 0;
else
return parseInt(el.currentStyle.top);
}
else {
return el.style.pixelTop;
}
}

I have modified your functions to include a Border version of the above ...
that Border version works in IE5 only (I presume) - there is a line I can't
guess at this far down in the DOM.

function getBodyBorderWidth() {
if (ie5) {
if (document.body.currentStyle.border == "auto")
return 0;
else
return parseInt(document.body.currentStyle.borderWidth);//hey hey guessed
it.
}
else {
return 0;//document.body.style.border.pixelBorderwidth???;//can't get this
one !
}
}

function _elementTop(el) {
var et = 0;
while (el) {
et += el.offsetTop;
el = el.offsetParent;
}
et += getBodyBorderWidth();
return et;
}

I do have another question. If I use ISMAP I get co-ords appended to url
(?234,857) ... this hasn't got any jscript hassles associated with it, but
can only use it on href ... which is not good if we need to play with the
co-ords client side.
I've tried href="javascript:myfunction()" but you just get the url
javascript:myfunction()?234,857
appearing in a new window.

Question :: Can we get to those co-ords client side ??? Any tricks of the
trade you could let me in on ???? I can't override the ISMAP pointing to
href, even when I capture mousevents for the whole doc.
The ISMAP seems to have put itself outside the document, like an IFrame, is
there anyway we can capture events for the ISMAP image seeing as it no
longer behavous like an image ??
(I think its an ActiveX control (a guess), built into Windows - can we get to it
?)

This javascript is too heavy, and IE based - it's a damn site easier to use an
IFrame.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Faith Hughes     Answered On: Jan 03

What about drag events? Save the first
point, drag the mouse and save the end-drag point... Voila. Maybe. Haven't tried
that ever, but could work.

BTW. Instead of those while statements you could also use for statement claverly
without a counter like:
for (o=el; o==null; o=o.offsetParent) top+=o.offsetTop;

But for that MAP problems that you have. No idea... Sorry. But I my college did
something simmilar. He had a floorplan of our company and has made an
administration console for connecting phone numbers of each person to the
floorplan. He entered a phone number and clicked on the picture of the
floorplan. He used this client side functionality:


if (document.layers)
{ // Netscape
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = captureMousePosition;
}
else if (document.all)
{ // Internet Explorer
document.onmousemove = captureMousePosition;
}
else if (document.getElementById)
{ // Netcsape 6
document.onmousemove = captureMousePosition;
}

// Global variables
xMousePos = 0;
yMousePos = 0;
xMousePosMax = 0;
yMousePosMax = 0;

function captureMousePosition(e)
{
if (document.layers)
{
xMousePos = e.pageX;
yMousePos = e.pageY;
xMousePosMax = window.innerWidth+window.pageXOffset;
yMousePosMax = window.innerHeight+window.pageYOffset;
}
else if (document.all)
{
xMousePos = window.event.x+document.body.scrollLeft;
yMousePos = window.event.y+document.body.scrollTop;
xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
yMousePosMax = document.body.clientHeight+document.body.scrollTop;
}
else if (document.getElementById)
{
xMousePos = e.pageX;
yMousePos = e.pageY;
xMousePosMax = window.innerWidth+window.pageXOffset;
yMousePosMax = window.innerHeight+window.pageYOffset;
}
}

function SendCoords()
{
Form1.txtcox.value = xMousePos;
Form1.txtcoy.value = yMousePos;
}

He had two hidden inputs on the form to send coords to server. He could've used
one also. Hope this code helps a little bit.

Why we need this in our company? We heve IP phones and we have a service on the
computer, that shows the person, that's calling you and his position within the
building. Clever? I think so. And also if you click on a certain place you can
dial the person there. The same thing can be made for inventury parts to easily
find something with the code.
As you can see, he didn't actualy used any ISMAP, but just mouse capture. He
could've subtracted the coordinates of the image  from it, but I think the first
thing on the page  was the image so he didn't have to.

 
Answer #2    Answered By: Dinh Tran     Answered On: Jan 03

I had already done that bit but the jcsript will be logged accordingly.

I think I am going to use the IFrame version  though, it's just cleaner.



<div id="sp"></div>
<center>
<IFrame id="ifr" name="ifr" src="ifr.htm" width="300" height="300"
scrolling="no" border="0" frameborder="0" ></IFrame>
</center>
<script>
var str = "";
str += "<html>\n";
str += "<body>\n";
str += "<script>\n";
str += " Xprev = 0;\n";
str += " Yprev = 0;\n";
str += " Ypos = 0;\n";
str += " Xpos = 0;\n";
str += " netscape = (document.layers) ? 1 : 0;\n";
str += "\n";
str += " if( netscape ){\n";
str += " window.captureEvents( Event.MOUSEMOVE );\n";
str += " function  nsMouse( evnt ){\n";
str += " Ypos = evnt.pageY;\n";
str += " Xpos = evnt.pageX;\n";
str += " top.window.status = Xpos + \",\" + Ypos;\n";
str += " top.document.getElementById(\"sp\").innerHTML = Xpos + \",\" +
Ypos;\n";
str += " }\n";
str += " window.onMouseMove = nsMouse;\n";
str += " }\n";
str += " else{\n";
str += " function ieMouse() {\n";
str += " Ypos = event.y + document.body.scrollTop;\n";
str += " Xpos = event.x + document.body.scrollLeft;\n";
str += " top.window.status = Xpos + \",\" + Ypos;\n";
str += " top.document.getElementById(\"sp\").innerHTML = Xpos + \",\" +
Ypos;\n";
str += " }\n";
str += " document.onmousemove = ieMouse;\n";
str += " }\n";
str += "<\/script>\n";
str += "<\/body>\n";
str += "<\/html>\n";
ifr.document.write(str);
</script>

 
Answer #3    Answered By: Ann Evans     Answered On: Jan 03

I want to create an array in vb at runtime of variable length x, can anyone pls
tell me how to do that?

 
Didn't find what you were looking for? Find more on jscript Or get search suggestion and latest updates.

Related Topics:



Tagged:  

 

Related Post