Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
javascript woes
#11
Quote:Download a Javascript framework like script.aculo.us, moo.fx, Rico or just work with Prototype and save yourself the trouble of writing something from scratch.
Gah, were is the fun in that! btw, he caught me on YIM, and we worked out what he wanted it to do, and got it to work right.. (He didn't like how mine locked to the centre of the image, the effect he was going for was to lock where the mouse clicked..)

What I came up w/ :
Code:
<html>
<head>

<script type="text/javascript">
var t
var x
var y
var init = 0
var offX
var offY
function getmouse(event){
    x=event.clientX
    y=event.clientY
    document.getElementById("coords").innerHTML = x+"  "+y
}

function showstuff(theid, event){
    if (init == 0) {
        init = 1
        offX = x - parseInt(document.getElementById(theid).style.left)
        offY = y - parseInt(document.getElementById(theid).style.top)
    }
    
    document.getElementById(theid).style.left = x - offX
    document.getElementById(theid).style.top = y - offY
    
    t=setTimeout("showstuff('scr1')", 50)
}

function unstick(){
    init = 0
    clearTimeout(t)
}
</script>

</head>

<body onmousemove="getmouse(event)">
<p id="coords"></p>
<div style="background: url('apache_pb22.gif'); width:259; height:32; position:absolute; left:100; top:0;" alt="scr1" id="scr1" onmousedown="showstuff('scr1', event)" onmouseup="unstick()"></div>
</body>
</html>

:roll:
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#12
More issues/questions to ANYONE:

1) How do I get the variable name of a javascript variable, if possible? E.G.

Code:
var hellothere = 5
document.write(??????????????)

I want the output to be the variable name, e.g.:"hellothere".

2) How do I maintain the hand cursor active after the user drags the image? This is the hand cursor I am talking about:
Code:
<style type="text/css">
.drag{
position:relative;
cursor:hand;
z-index: 100;
}
</style>

Thanks!

EDIT: Forget about the lone scrollbar. I need to access the scrollbar data... how do I do it...
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#13
Dunno about the first. Never needed to do it.

For the second, I'm not clear what you want. Your style shows that the cursor will be a hand while being dragged.

Btw, don't use the cursor property.

Lastly, just google scrollbar CSS.
Again, don't do this, it's not standards compliant.
·~¹'°¨°'¹i|¡~æthérFòx~¡|i¹'°¨°'¹~·-
avinash.vora - http://www.avinashv.net
Reply
#14
God man. Compliance in the face of utter good stuff that works on every good browser... I don't think I'm going to be compliant!
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#15
To make the hand appear when the mouse is over it:

Code:
<div style="background: url('image_whatever.gif'); width:259; height:32; position:absolute; left:100; top:0; cursor: pointer; " alt="scr1" id="scr1" onmousedown="showstuff('scr1', event)" onmouseup="unstick()"></div>

The other, I don't know of anything like that as of yet....

Edit: Cursor: hand; .. That's for IE, not sure if you need both, or both IE and FF notice it.. FF prolly does knowing them:

More info: http://www.w3schools.com/css/pr_class_cursor.asp
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#16
I fixed it, mostly.

But here's another question....

You know the resize bars in an Internet Explorer window... the ones that resize the window... Is there any standard way to do that with HTML or Javascript? I have a div and I want to make it resizable with resize bars on all 4 sides.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#17
On the DIV in question, you use precents to set it's width and height, and when the browser changes size, so will the DIV..

:winkwink:
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#18
Quote:God man. Compliance in the face of utter good stuff that works on every good browser... I don't think I'm going to be compliant!

Actually, it's because this "good stuff" is NOT standards compliant that it does NOT work on "every good browser".

This anti-compliancy crap pisses me off - you people have no idea what you are talking about. If you truly understood the benefits of complaint and semantic code you'd be lapping it up like a dog.
·~¹'°¨°'¹i|¡~æthérFòx~¡|i¹'°¨°'¹~·-
avinash.vora - http://www.avinashv.net
Reply
#19
I want the user to resize it, not me.

The cursor stuff does work on IE and Mozilla, though, and that's 99%... good enough for me.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#20
LOL spambots...
.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)