Old 31st October 2004, 16:51   #1
Wolfgang
Forum King
 
Join Date: Mar 2004
Posts: 3,069
Javascript help.

I have been trying to make my active desktop randomly display images when I click on a link. This is the header bit:

code:
<script language="JavaScript">

function pickimg(){
var imagenumber = 6 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1;
images = new Array
images[1] = "desktop\\Pics\\1.jpg"
images[2] = "desktop\\Pics\\2.jpg"
images[3] = "desktop\\Pics\\3.jpg"
images[4] = "desktop\\Pics\\4.jpg"
images[5] = "desktop\\Pics\\5.jpg"
images[6] = "desktop\\Pics\\6.jpg"
var image = images[rand1]
document.randimg.src = image
}
</script>



Then in the <body> tag is this:

<body background="maras.jpg" onLoad="pickimg();">

And the link contains this:

<a onClick="MM_showHideLayers('box','','show');">Click</a>

The link is in a layer of its own, and on clicking, it is supposed to open a new layer:

<div id="box" style="position:absolute; left:0px; top:0px; width:1024px; height:768px; z-index:2; visibility:hidden;">
<img src="pickimg(image);"></div>

I'm pretty sure the problem is with the img src bit, but I don't know what it's supposed to be.

Any help please?
Wolfgang is offline   Reply With Quote
Old 31st October 2004, 17:23   #2
yenerich
Banned
 
Join Date: Sep 2004
Posts: 295
code:
<img src="javascript : pickimg(image);">
yenerich is offline   Reply With Quote
Old 31st October 2004, 17:47   #3
Wolfgang
Forum King
 
Join Date: Mar 2004
Posts: 3,069
thanks.

it still doesn't work though...
Wolfgang is offline   Reply With Quote
Old 31st October 2004, 18:01   #4
PulseDriver
w3 addict
(Major Dude)
 
PulseDriver's Avatar
 
Join Date: May 2004
Location: Norway
Posts: 1,806
Lots of error here, and get a grip on syntax, some lines end with ; and some don't. I know it's not required to use ; to terminate a line, but if you do, it's much easier to read a script, espeseially if a line is wrapped.

Gimme some minutes and I'll have a script you might be able to use

09 F9 11 01 9D 74 E8 5B D8 41 56 C3 63 56 81 C0
PulseDriver is offline   Reply With Quote
Old 31st October 2004, 18:18   #5
PulseDriver
w3 addict
(Major Dude)
 
PulseDriver's Avatar
 
Join Date: May 2004
Location: Norway
Posts: 1,806
Here

code:

<html>
<head>

<title>Random Image</title>

<script language="JavaScript">

<!-- Old browser prosedure

function pickImg(newImg){
var imgNum = 6;
var ranNum = Math.random();
var rand1 = Math.round( (imgNum-1) * ranNum);

images = new Array();
images[0] = "1.gif";
images[1] = "2.gif";
images[2] = "3.gif";
images[3] = "4.gif";
images[4] = "5.gif";
images[5] = "6.gif";
newImg = images[rand1];
document.randimg.src = newImg;
}

// -->

</script>

</head>

<body onLoad="pickImg(randimg)">

<a href="#" onClick="pickImg(randimg)"><img src="click.gif" border="0"></a>

<img src="0.gif" name="randimg">

</body>
</html>



I have attached the file with some images in the zipfile below Hope this is what you were looking for
Attached Files
File Type: zip pickimg.zip (18.3 KB, 119 views)

09 F9 11 01 9D 74 E8 5B D8 41 56 C3 63 56 81 C0
PulseDriver is offline   Reply With Quote
Old 31st October 2004, 18:35   #6
Wolfgang
Forum King
 
Join Date: Mar 2004
Posts: 3,069
Tusind tak!
Wolfgang is offline   Reply With Quote
Old 31st October 2004, 18:37   #7
PulseDriver
w3 addict
(Major Dude)
 
PulseDriver's Avatar
 
Join Date: May 2004
Location: Norway
Posts: 1,806
np

09 F9 11 01 9D 74 E8 5B D8 41 56 C3 63 56 81 C0
PulseDriver is offline   Reply With Quote
Old 1st November 2004, 19:26   #8
xzxzzx
Forum King
 
xzxzzx's Avatar
 
Join Date: Aug 2002
Posts: 7,254
Quote:
Originally posted by Wolfgang
Tusind tak!
Hmm... "Thank you very much!"?

Freedom of speech is the basic freedom of humanity. When you've lost that, you've lost everything.
1\/\/4y 34|<$p4y 1gp4y 33714y, 0d4y 0uy4y? | Roses are #FF0000; Violets are #0000FF; chown -R ${YOU} ~/base
The DMCA. It really is that bad. : Count for your life.
xzxzzx is offline   Reply With Quote
Old 1st November 2004, 22:12   #9
Mattress
Forum King
 
Mattress's Avatar
 
Join Date: Jun 2003
Location: Milwaukee
Posts: 4,577
I turned on active desktop and loaded a web page for my background and it turned off the transparency for my desktop icons, what's up with that?
Mattress is offline   Reply With Quote
Old 2nd November 2004, 11:56   #10
Wolfgang
Forum King
 
Join Date: Mar 2004
Posts: 3,069
Quote:
Originally posted by xzxzzx
Hmm... "Thank you very much!"?
A thousand thanks. It's Danish. I assumed it would be the same in Norwegian.

Mattress: I don't know. It does happen to me too. I just got rid of them all and put links to what I want as part of the Active Desktop (that's what it's for). However, if I removed ALL of them, the active desktop would disappear. So I've had to keep one. I mada an invisible icon for the shortcut, and an invisible character for the caption. So it's gone. Still a drag though.
Wolfgang is offline   Reply With Quote
Old 2nd November 2004, 13:38   #11
xzxzzx
Forum King
 
xzxzzx's Avatar
 
Join Date: Aug 2002
Posts: 7,254
Quote:
Originally posted by Wolfgang
A thousand thanks. It's Danish. I assumed it would be the same in Norwegian.
Ah. Thanks for the clarification.

Freedom of speech is the basic freedom of humanity. When you've lost that, you've lost everything.
1\/\/4y 34|<$p4y 1gp4y 33714y, 0d4y 0uy4y? | Roses are #FF0000; Violets are #0000FF; chown -R ${YOU} ~/base
The DMCA. It really is that bad. : Count for your life.
xzxzzx is offline   Reply With Quote
Old 2nd November 2004, 19:45   #12
PulseDriver
w3 addict
(Major Dude)
 
PulseDriver's Avatar
 
Join Date: May 2004
Location: Norway
Posts: 1,806
Norwegian: Tusen Takk

09 F9 11 01 9D 74 E8 5B D8 41 56 C3 63 56 81 C0
PulseDriver is offline   Reply With Quote
Old 3rd November 2004, 11:19   #13
Wolfgang
Forum King
 
Join Date: Mar 2004
Posts: 3,069
Fint nok!

I didn't want to start a new thread on something so small, but this is annoying me. What is the little dotted box called around thinks you have selected? Like this:



Also, is there some kind of css that will disable it when you click on links/images on a webpage?
Wolfgang is offline   Reply With Quote
Old 3rd November 2004, 14:43   #14
Mattress
Forum King
 
Mattress's Avatar
 
Join Date: Jun 2003
Location: Milwaukee
Posts: 4,577
it's the active link, there are four states of links in CSS

a
a:hover
a:active
a:visited

active links are links that have been clicked on, usually you don't see them too much because clicking on a link usually sends you to a new page and the clicked on link goes away. but you can see them if the link just invokes some javascript or a frame or something.

Anyway, the little dotted box is not something that is specified in CSS so I don't believe you can get rid of it like that. Though it is part of IE, (Opera doesn't give you the box, firefox does, IE does) so microsoft might have some proprietary css that can turn it off, but I doubt it.
Mattress is offline   Reply With Quote
Old 3rd November 2004, 17:27   #15
PulseDriver
w3 addict
(Major Dude)
 
PulseDriver's Avatar
 
Join Date: May 2004
Location: Norway
Posts: 1,806
As far as I know, there is nothing that can disable the border around the active object, at least not for IE.

For html specs. it's <body alink="colorname/hex">

09 F9 11 01 9D 74 E8 5B D8 41 56 C3 63 56 81 C0
PulseDriver is offline   Reply With Quote
Old 4th November 2004, 13:38   #16
Wolfgang
Forum King
 
Join Date: Mar 2004
Posts: 3,069
Actually, I've just noticed that in the IE I'm using at college the box isn't there, but on my IE at home it is. And I have IE 6. Maybe it's an SP2 thing. It's the only thing I haven't got from Windows Update.
Wolfgang is offline   Reply With Quote
Old 2nd December 2004, 12:25   #17
Wolfgang
Forum King
 
Join Date: Mar 2004
Posts: 3,069
Reviving this thread becuase there's no point starting another, as it's more or less the same topic.

I'm using a script to make layers draggable in an HTML page. It is triggered by a click on a link which makes it possible to drag one of the layers across the screen. I want to click on a link (or the same one as the original one) to stop the layer-dragging, i.e. stop the script from functioning, until the link is clicked again. I've googled for it but have found no answer. How do I stop the script from "running"? Any help much appreciated.

This is the script:


code:
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_dragLayer(objName,x,hL,hT,hW,hH,toFront,dropBack,cU,cD,cL,cR,targL,targT,tol,dropJS,et,dragJS) { //v4.01
var i,j,aLayer,retVal,curDrag=null,curLeft,curTop,IE=document.all,NS4=document.layers;
var NS6=(!IE&&document.getElementById), NS=(NS4||NS6); if (!IE && !NS) return false;
retVal = true; if(IE && event) event.returnValue = true;
if (MM_dragLayer.arguments.length > 1) {
curDrag = MM_findObj(objName); if (!curDrag) return false;
if (!document.allLayers) { document.allLayers = new Array();
with (document) if (NS4) { for (i=0; i<layers.length; i++) allLayers[i]=layers[i];
for (i=0; i<allLayers.length; i++) if (allLayers[i].document && allLayers[i].document.layers)
with (allLayers[i].document) for (j=0; j<layers.length; j++) allLayers[allLayers.length]=layers[j];
} else {
if (NS6) { var spns = getElementsByTagName("span"); var all = getElementsByTagName("div");
for (i=0;i<spns.length;i++) if (spns[i].style&&spns[i].style.position) allLayers[allLayers.length]=spns[i];}
for (i=0;i<all.length;i++) if (all[i].style&&all[i].style.position) allLayers[allLayers.length]=all[i];
} }
curDrag.MM_dragOk=true; curDrag.MM_targL=targL; curDrag.MM_targT=targT;
curDrag.MM_tol=Math.pow(tol,2); curDrag.MM_hLeft=hL; curDrag.MM_hTop=hT;
curDrag.MM_hWidth=hW; curDrag.MM_hHeight=hH; curDrag.MM_toFront=toFront;
curDrag.MM_dropBack=dropBack; curDrag.MM_dropJS=dropJS;
curDrag.MM_everyTime=et; curDrag.MM_dragJS=dragJS;
curDrag.MM_oldZ = (NS4)?curDrag.zIndex:curDrag.style.zIndex;
curLeft= (NS4)?curDrag.leftNS6)?parseInt(curDrag.style.left):curDrag.style.pixelLeft;
if (String(curLeft)=="NaN") curLeft=0; curDrag.MM_startL = curLeft;
curTop = (NS4)?curDrag.topNS6)?parseInt(curDrag.style.top):curDrag.style.pixelTop;
if (String(curTop)=="NaN") curTop=0; curDrag.MM_startT = curTop;
curDrag.MM_bL=(cL<0)?null:curLeft-cL; curDrag.MM_bT=(cU<0)?null:curTop-cU;
curDrag.MM_bR=(cR<0)?null:curLeft+cR; curDrag.MM_bB=(cD<0)?null:curTop+cD;
curDrag.MM_LEFTRIGHT=0; curDrag.MM_UPDOWN=0; curDrag.MM_SNAPPED=false; //use in your JS!
document.onmousedown = MM_dragLayer; document.onmouseup = MM_dragLayer;
if (NS) document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
} else {
var theEvent = ((NS)?objName.type:event.type);
if (theEvent == 'mousedown') {
var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
var maxDragZ=null; document.MM_maxZ = 0;
for (i=0; i<document.allLayers.length; i++) { aLayer = document.allLayers[i];
var aLayerZ = (NS4)?aLayer.zIndexarseInt(aLayer.style.zIndex);
if (aLayerZ > document.MM_maxZ) document.MM_maxZ = aLayerZ;
var isVisible = (((NS4)?aLayer.visibility:aLayer.style.visibility).indexOf('hid') == -1);
if (aLayer.MM_dragOk != null && isVisible) with (aLayer) {
var parentL=0; var parentT=0;
if (NS6) { parentLayer = aLayer.parentNode;
while (parentLayer != null && parentLayer.style.position) {
parentL += parseInt(parentLayer.offsetLeft); parentT += parseInt(parentLayer.offsetTop);
parentLayer = parentLayer.parentNode;
} } else if (IE) { parentLayer = aLayer.parentElement;
while (parentLayer != null && parentLayer.style.position) {
parentL += parentLayer.offsetLeft; parentT += parentLayer.offsetTop;
parentLayer = parentLayer.parentElement; } }
var tmpX=mouseX-(((NS4)?pageX(NS6)?parseInt(style.left):style.pixelLeft)+parentL)+MM_hLeft);
var tmpY=mouseY-(((NS4)?pageY(NS6)?parseInt(style.top):style.pixelTop) +parentT)+MM_hTop);
if (String(tmpX)=="NaN") tmpX=0; if (String(tmpY)=="NaN") tmpY=0;
var tmpW = MM_hWidth; if (tmpW <= 0) tmpW += ((NS4)?clip.width ffsetWidth);
var tmpH = MM_hHeight; if (tmpH <= 0) tmpH += ((NS4)?clip.heightffsetHeight);
if ((0 <= tmpX && tmpX < tmpW && 0 <= tmpY && tmpY < tmpH) && (maxDragZ == null
|| maxDragZ <= aLayerZ)) { curDrag = aLayer; maxDragZ = aLayerZ; } } }
if (curDrag) {
document.onmousemove = MM_dragLayer; if (NS4) document.captureEvents(Event.MOUSEMOVE);
curLeft = (NS4)?curDrag.leftNS6)?parseInt(curDrag.style.left):curDrag.style.pixelLeft;
curTop = (NS4)?curDrag.topNS6)?parseInt(curDrag.style.top):curDrag.style.pixelTop;
if (String(curLeft)=="NaN") curLeft=0; if (String(curTop)=="NaN") curTop=0;
MM_oldX = mouseX - curLeft; MM_oldY = mouseY - curTop;
document.MM_curDrag = curDrag; curDrag.MM_SNAPPED=false;
if(curDrag.MM_toFront) {
eval('curDrag.'+((NS4)?'':'style.')+'zIndex=document.MM_maxZ+1');
if (!curDrag.MM_dropBack) document.MM_maxZ++; }
retVal = false; if(!NS4&&!NS6) event.returnValue = false;
} } else if (theEvent == 'mousemove') {
if (document.MM_curDrag) with (document.MM_curDrag) {
var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
newLeft = mouseX-MM_oldX; newTop = mouseY-MM_oldY;
if (MM_bL!=null) newLeft = Math.max(newLeft,MM_bL);
if (MM_bR!=null) newLeft = Math.min(newLeft,MM_bR);
if (MM_bT!=null) newTop = Math.max(newTop ,MM_bT);
if (MM_bB!=null) newTop = Math.min(newTop ,MM_bB);
MM_LEFTRIGHT = newLeft-MM_startL; MM_UPDOWN = newTop-MM_startT;
if (NS4) {left = newLeft; top = newTop;}
else if (NS6){style.left = newLeft; style.top = newTop;}
else {style.pixelLeft = newLeft; style.pixelTop = newTop;}
if (MM_dragJS) eval(MM_dragJS);
retVal = false; if(!NS) event.returnValue = false;
} } else if (theEvent == 'mouseup') {
document.onmousemove = null;
if (NS) document.releaseEvents(Event.MOUSEMOVE);
if (NS) document.captureEvents(Event.MOUSEDOWN); //for mac NS
if (document.MM_curDrag) with (document.MM_curDrag) {
if (typeof MM_targL =='number' && typeof MM_targT == 'number' &&
(Math.pow(MM_targL-((NS4)?leftNS6)?parseInt(style.left):style.pixelLeft),2)+
Math.pow(MM_targT-((NS4)?topNS6)?parseInt(style.top):style.pixelTop),2))<=MM_tol) {
if (NS4) {left = MM_targL; top = MM_targT;}
else if (NS6) {style.left = MM_targL; style.top = MM_targT;}
else {style.pixelLeft = MM_targL; style.pixelTop = MM_targT;}
MM_SNAPPED = true; MM_LEFTRIGHT = MM_startL-MM_targL; MM_UPDOWN = MM_startT-MM_targT; }
if (MM_everyTime || MM_SNAPPED) eval(MM_dropJS);
if(MM_dropBack) {if (NS4) zIndex = MM_oldZ; else style.zIndex = MM_oldZ;}
retVal = false; if(!NS) event.returnValue = false; }
document.MM_curDrag = null;
}
if (NS) document.routeEvent(objName);
} return retVal;
}
//-->

Wolfgang is offline   Reply With Quote
Old 2nd December 2004, 14:36   #18
xzxzzx
Forum King
 
xzxzzx's Avatar
 
Join Date: Aug 2002
Posts: 7,254
Um, you might want to repost that, but this time, turn off smilies.

Freedom of speech is the basic freedom of humanity. When you've lost that, you've lost everything.
1\/\/4y 34|<$p4y 1gp4y 33714y, 0d4y 0uy4y? | Roses are #FF0000; Violets are #0000FF; chown -R ${YOU} ~/base
The DMCA. It really is that bad. : Count for your life.
xzxzzx is offline   Reply With Quote
Old 2nd December 2004, 16:54   #19
Wolfgang
Forum King
 
Join Date: Mar 2004
Posts: 3,069
Oops.

I'm using a script to make layers draggable in an HTML page. It is triggered by a click on a link which makes it possible to drag one of the layers across the screen. I want to click on a link (or the same one as the original one) to stop the layer-dragging, i.e. stop the script from functioning, until the link is clicked again. I've googled for it but have found no answer. How do I stop the script from "running"? Any help much appreciated.

This is the script:


code:
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_dragLayer(objName,x,hL,hT,hW,hH,toFront,dropBack,cU,cD,cL,cR,targL,targT,tol,dropJS,et,dragJS) { //v4.01
var i,j,aLayer,retVal,curDrag=null,curLeft,curTop,IE=document.all,NS4=document.layers;
var NS6=(!IE&&document.getElementById), NS=(NS4||NS6); if (!IE && !NS) return false;
retVal = true; if(IE && event) event.returnValue = true;
if (MM_dragLayer.arguments.length > 1) {
curDrag = MM_findObj(objName); if (!curDrag) return false;
if (!document.allLayers) { document.allLayers = new Array();
with (document) if (NS4) { for (i=0; i<layers.length; i++) allLayers[i]=layers[i];
for (i=0; i<allLayers.length; i++) if (allLayers[i].document && allLayers[i].document.layers)
with (allLayers[i].document) for (j=0; j<layers.length; j++) allLayers[allLayers.length]=layers[j];
} else {
if (NS6) { var spns = getElementsByTagName("span"); var all = getElementsByTagName("div");
for (i=0;i<spns.length;i++) if (spns[i].style&&spns[i].style.position) allLayers[allLayers.length]=spns[i];}
for (i=0;i<all.length;i++) if (all[i].style&&all[i].style.position) allLayers[allLayers.length]=all[i];
} }
curDrag.MM_dragOk=true; curDrag.MM_targL=targL; curDrag.MM_targT=targT;
curDrag.MM_tol=Math.pow(tol,2); curDrag.MM_hLeft=hL; curDrag.MM_hTop=hT;
curDrag.MM_hWidth=hW; curDrag.MM_hHeight=hH; curDrag.MM_toFront=toFront;
curDrag.MM_dropBack=dropBack; curDrag.MM_dropJS=dropJS;
curDrag.MM_everyTime=et; curDrag.MM_dragJS=dragJS;
curDrag.MM_oldZ = (NS4)?curDrag.zIndex:curDrag.style.zIndex;
curLeft= (NS4)?curDrag.left:(NS6)?parseInt(curDrag.style.left):curDrag.style.pixelLeft;
if (String(curLeft)=="NaN") curLeft=0; curDrag.MM_startL = curLeft;
curTop = (NS4)?curDrag.top:(NS6)?parseInt(curDrag.style.top):curDrag.style.pixelTop;
if (String(curTop)=="NaN") curTop=0; curDrag.MM_startT = curTop;
curDrag.MM_bL=(cL<0)?null:curLeft-cL; curDrag.MM_bT=(cU<0)?null:curTop-cU;
curDrag.MM_bR=(cR<0)?null:curLeft+cR; curDrag.MM_bB=(cD<0)?null:curTop+cD;
curDrag.MM_LEFTRIGHT=0; curDrag.MM_UPDOWN=0; curDrag.MM_SNAPPED=false; //use in your JS!
document.onmousedown = MM_dragLayer; document.onmouseup = MM_dragLayer;
if (NS) document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
} else {
var theEvent = ((NS)?objName.type:event.type);
if (theEvent == 'mousedown') {
var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
var maxDragZ=null; document.MM_maxZ = 0;
for (i=0; i<document.allLayers.length; i++) { aLayer = document.allLayers[i];
var aLayerZ = (NS4)?aLayer.zIndex:parseInt(aLayer.style.zIndex);
if (aLayerZ > document.MM_maxZ) document.MM_maxZ = aLayerZ;
var isVisible = (((NS4)?aLayer.visibility:aLayer.style.visibility).indexOf('hid') == -1);
if (aLayer.MM_dragOk != null && isVisible) with (aLayer) {
var parentL=0; var parentT=0;
if (NS6) { parentLayer = aLayer.parentNode;
while (parentLayer != null && parentLayer.style.position) {
parentL += parseInt(parentLayer.offsetLeft); parentT += parseInt(parentLayer.offsetTop);
parentLayer = parentLayer.parentNode;
} } else if (IE) { parentLayer = aLayer.parentElement;
while (parentLayer != null && parentLayer.style.position) {
parentL += parentLayer.offsetLeft; parentT += parentLayer.offsetTop;
parentLayer = parentLayer.parentElement; } }
var tmpX=mouseX-(((NS4)?pageX:((NS6)?parseInt(style.left):style.pixelLeft)+parentL)+MM_hLeft);
var tmpY=mouseY-(((NS4)?pageY:((NS6)?parseInt(style.top):style.pixelTop) +parentT)+MM_hTop);
if (String(tmpX)=="NaN") tmpX=0; if (String(tmpY)=="NaN") tmpY=0;
var tmpW = MM_hWidth; if (tmpW <= 0) tmpW += ((NS4)?clip.width :offsetWidth);
var tmpH = MM_hHeight; if (tmpH <= 0) tmpH += ((NS4)?clip.height:offsetHeight);
if ((0 <= tmpX && tmpX < tmpW && 0 <= tmpY && tmpY < tmpH) && (maxDragZ == null
|| maxDragZ <= aLayerZ)) { curDrag = aLayer; maxDragZ = aLayerZ; } } }
if (curDrag) {
document.onmousemove = MM_dragLayer; if (NS4) document.captureEvents(Event.MOUSEMOVE);
curLeft = (NS4)?curDrag.left:(NS6)?parseInt(curDrag.style.left):curDrag.style.pixelLeft;
curTop = (NS4)?curDrag.top:(NS6)?parseInt(curDrag.style.top):curDrag.style.pixelTop;
if (String(curLeft)=="NaN") curLeft=0; if (String(curTop)=="NaN") curTop=0;
MM_oldX = mouseX - curLeft; MM_oldY = mouseY - curTop;
document.MM_curDrag = curDrag; curDrag.MM_SNAPPED=false;
if(curDrag.MM_toFront) {
eval('curDrag.'+((NS4)?'':'style.')+'zIndex=document.MM_maxZ+1');
if (!curDrag.MM_dropBack) document.MM_maxZ++; }
retVal = false; if(!NS4&&!NS6) event.returnValue = false;
} } else if (theEvent == 'mousemove') {
if (document.MM_curDrag) with (document.MM_curDrag) {
var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
newLeft = mouseX-MM_oldX; newTop = mouseY-MM_oldY;
if (MM_bL!=null) newLeft = Math.max(newLeft,MM_bL);
if (MM_bR!=null) newLeft = Math.min(newLeft,MM_bR);
if (MM_bT!=null) newTop = Math.max(newTop ,MM_bT);
if (MM_bB!=null) newTop = Math.min(newTop ,MM_bB);
MM_LEFTRIGHT = newLeft-MM_startL; MM_UPDOWN = newTop-MM_startT;
if (NS4) {left = newLeft; top = newTop;}
else if (NS6){style.left = newLeft; style.top = newTop;}
else {style.pixelLeft = newLeft; style.pixelTop = newTop;}
if (MM_dragJS) eval(MM_dragJS);
retVal = false; if(!NS) event.returnValue = false;
} } else if (theEvent == 'mouseup') {
document.onmousemove = null;
if (NS) document.releaseEvents(Event.MOUSEMOVE);
if (NS) document.captureEvents(Event.MOUSEDOWN); //for mac NS
if (document.MM_curDrag) with (document.MM_curDrag) {
if (typeof MM_targL =='number' && typeof MM_targT == 'number' &&
(Math.pow(MM_targL-((NS4)?left:(NS6)?parseInt(style.left):style.pixelLeft),2)+
Math.pow(MM_targT-((NS4)?top:(NS6)?parseInt(style.top):style.pixelTop),2))<=MM_tol) {
if (NS4) {left = MM_targL; top = MM_targT;}
else if (NS6) {style.left = MM_targL; style.top = MM_targT;}
else {style.pixelLeft = MM_targL; style.pixelTop = MM_targT;}
MM_SNAPPED = true; MM_LEFTRIGHT = MM_startL-MM_targL; MM_UPDOWN = MM_startT-MM_targT; }
if (MM_everyTime || MM_SNAPPED) eval(MM_dropJS);
if(MM_dropBack) {if (NS4) zIndex = MM_oldZ; else style.zIndex = MM_oldZ;}
retVal = false; if(!NS) event.returnValue = false; }
document.MM_curDrag = null;
}
if (NS) document.routeEvent(objName);
} return retVal;
}
//-->

Wolfgang is offline   Reply With Quote
Old 10th December 2004, 08:25   #20
PulseDriver
w3 addict
(Major Dude)
 
PulseDriver's Avatar
 
Join Date: May 2004
Location: Norway
Posts: 1,806
I know a solution... you can have some scripts that is made by Danny Goodman which came with my JS 4 bible, and they are much easier to understand than program made code. I don't know where you got that code, but my guess would be MacroMedia as of the MM_find_obj().

I'll post them when I get home.

09 F9 11 01 9D 74 E8 5B D8 41 56 C3 63 56 81 C0
PulseDriver is offline   Reply With Quote
Old 10th December 2004, 16:26   #21
Wolfgang
Forum King
 
Join Date: Mar 2004
Posts: 3,069
Yes, they are bundled with Macromedia Dreamweaver. There are other around on the internet.

Thanks a lot.
Wolfgang is offline   Reply With Quote
Old 14th December 2004, 08:19   #22
PulseDriver
w3 addict
(Major Dude)
 
PulseDriver's Avatar
 
Join Date: May 2004
Location: Norway
Posts: 1,806
Forgot I lend away my bible to my brother.. :S I'll try to locate the script at the internet.

09 F9 11 01 9D 74 E8 5B D8 41 56 C3 63 56 81 C0
PulseDriver is offline   Reply With Quote
Old 14th December 2004, 10:17   #23
Wolfgang
Forum King
 
Join Date: Mar 2004
Posts: 3,069
Thanks.
Wolfgang is offline   Reply With Quote
Old 14th December 2004, 14:30   #24
PulseDriver
w3 addict
(Major Dude)
 
PulseDriver's Avatar
 
Join Date: May 2004
Location: Norway
Posts: 1,806
I found the example by Danny Goodman which I had in mind.

The url for the example itself is:
http://www.dannyg.com/examples/puzzle/mapgame.htm

And it also uses an API file (also written by DG) located:
http://www.dannyg.com/examples/puzzle/DHTMLapi.js

You prolly have to rewrite alot of HTML, but at least if you manage to use this, you'll know what really happens

09 F9 11 01 9D 74 E8 5B D8 41 56 C3 63 56 81 C0
PulseDriver is offline   Reply With Quote
Old 14th December 2004, 14:41   #25
Wolfgang
Forum King
 
Join Date: Mar 2004
Posts: 3,069
Thanks, I'll check it out when I get home. AFAIK, the macromedia script does that too, including the snapping to positions with a certain tolerance.
Wolfgang is offline   Reply With Quote
Old 14th December 2004, 14:45   #26
PulseDriver
w3 addict
(Major Dude)
 
PulseDriver's Avatar
 
Join Date: May 2004
Location: Norway
Posts: 1,806
Yep, and the DHTML API file contains more than just one fuction, as far as I remember, it can do different stuff, so if you learn the functions within it, you can do alot of fancy DTHML with it

AND much easier to modify

09 F9 11 01 9D 74 E8 5B D8 41 56 C3 63 56 81 C0
PulseDriver is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Community Center > General Discussions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump