Bij een click op een image van 1000X700 moet d.m.v. een javascript een gif verschijnen op de juiste plaats en de coordinaten van het gifje in een textveld voor verzending.
Dit is het script tot nu toe, ik krijg het niet goed werkend.
<script type="text/JavaScript">
<!-- Chief...
var windowX=windowY=locX=locY=x=y=0;
var locationX=0;
var locationY=0;
window.onload=init;

function init()
{
if (window.Event)
{
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove=getXY;
}

function getXY(e)
{
windowX=(window.Event)?e.pageX:event.clientX;
windowY=(window.Event)?e.pageY:event.clientY;
locX=document.getElementById('daPic').offsetLeft;
locY=document.getElementById('daPic').offsetTop;
x=windowX-locX-1;
y=windowY-locY-1;
}
function doStuff()
{
locationX=x;
locationY=y;
}
function setStuff()
{
if (locationX!=0 && locationY!=0)
{
document.getElementById('someText').style.display="block";
document.getElementById('someText').style.top=locationY;
document.getElementById('someText').style.left=locationX;
}
}
//-->
</script>


<script language="JavaScript1.2">
<!-- Original: CodeLifter.com ([email protected]) -->
<!-- Web Site: http://www.codelifter.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
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) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else { // grab the x-y pos.s if browser is NS
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;
return true;
}
// End -->
</script>

<form name="Show">
X <input type="text" name="MouseX" value="0" size="4">
Y <input type="text" name="MouseY" value="0" size="4">
</form>

<a href="nieuw.asp" onClick="setStuff(); return false;">
<img src="map_bg.png" border="0" width="1000" height="700" id="daPic" name="daPic" onClick="doStuff();">
<div id="someText" style="border:0px solid black; display:none; z-index:100; position:absolute;"><img src="fa.gif" border="0"></div></a>

Hmmm, niemand?
vitens schreef op 12.10.2005 13:49
Nee, dat lukt me dus niet. De pixels zijn 9*9. Het veld mag best groter.
Bij voorbaat dank voor het voorbeeld.


Okee, ga nog maar eens op dezelfde pagina kijken. De pixels zijn kleiner en de waarde wordt nu opgeslagen in een tekstveld.
Jan Koehoorn schreef op 13.10.2005 14:53
[quote=vitens schreef op 12.10.2005 13:49]Nee, dat lukt me dus niet. De pixels zijn 9*9. Het veld mag best groter.
Bij voorbaat dank voor het voorbeeld.


Okee, ga nog maar eens op dezelfde pagina kijken. De pixels zijn kleiner en de waarde wordt nu opgeslagen in een tekstveld.[/quote]

Dat is precies hoe ik het wilde hebben. De pagina werkt alleen niet in IE.
vitens schreef op 13.10.2005 15:44
Dat is precies hoe ik het wilde hebben. De pagina werkt alleen niet in IE.


Nu wel!

:-)
[qoute]LET OP: wacht tot de pagina helemaal geladen is!

Deze is gemaakt naar aanleiding van een vraag op www.phphulp.nl

Misschien kun je de code gebruiken voor een spelletje of zo! :-))
[/qoute]


Misgien voor een schietspelletje :P
Jan Koehoorn schreef op 13.10.2005 17:36


Nu wel!

:-)


Geweldig Jan, hier kan ik echt iets mee!
In ie werkt het nu ook perfect. Ik dacht al dat het in die /-/ zat. Bedankt voor je snelle en overzichtelijke hulp.
Graag gedaan! :-)
12. Are you worried about copy-cats/rip-offs? New!

Not at all. It is bound to happen (this is the internet afterall), and infact, I think it will work in my favour. They say imitation is the sincerest form of flattery. So I think any copy-cat sites will only have pure comedy value, whereas mine possibly has a bit of comedy PLUS some actual pull in terms of advertising dollars (I will be able to afford swanky socks, they will only get to buy crappy ones probably! They could have my old ones, if they like).

So I say good luck to the imitators! While in my opinion it's not very cool - I would prefer to come up with something original - in many ways the act of copying (perhaps more on a subconcious level than anything) is the basis of all creativity. But yeah, really bad rip-offs are seriously lame - I mean, if you're gonna copy the concept, at least come up with your own design and text!

UK folks > am I bothered? :)


Tis bijna nog een 1 op 1 kopie ook. In zijn woorden: bad rip-offs are seriously lame...
Mijn pixels zijn gratis en aan het design wordt gewerkt.
:D

Reageren