timbaker1991
10-02-2011, 07:46 PM
Hi
I've got a HTML5 canvas graph and want to make, using JavaScript a small pop up appear when you click on a dot on the graph.
Mock up:
https://picasaweb.google.com/108559654686816990572/RandomPhotos?authuser=0&feat=directlink
I've got this code
<script type="text/javascript">
var _get = (function(){
var i, p,x, obj = {};
x = location.search.slice(1).split('&');
for(var i = 0; i < x.length;i++){
p = x[i].indexOf('=');
obj[x[i].slice(0,p)] =
decodeURIComponent(x[i].slice(p+1));
};
return obj
})();
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
var x = '400';
var d=document.getElementById("myCanvas");
var ctx=d.getContext("2d");
ctx.beginPath();
ctx.arc(75, 75, 5, 0, Math.PI*2, true);
ctx.closePath();
ctx.fill();
</script>
I have found how I can do it by having a mouse over but it needs to be on click as they need to be able to then click on a link in the pop up area. The content of the pop up will come from a POST string set on the previous page.
I am a newbie to JavaScript although well experienced PHP programmer - can someone point me in the right direction please? Thank you
I've got a HTML5 canvas graph and want to make, using JavaScript a small pop up appear when you click on a dot on the graph.
Mock up:
https://picasaweb.google.com/108559654686816990572/RandomPhotos?authuser=0&feat=directlink
I've got this code
<script type="text/javascript">
var _get = (function(){
var i, p,x, obj = {};
x = location.search.slice(1).split('&');
for(var i = 0; i < x.length;i++){
p = x[i].indexOf('=');
obj[x[i].slice(0,p)] =
decodeURIComponent(x[i].slice(p+1));
};
return obj
})();
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
var x = '400';
var d=document.getElementById("myCanvas");
var ctx=d.getContext("2d");
ctx.beginPath();
ctx.arc(75, 75, 5, 0, Math.PI*2, true);
ctx.closePath();
ctx.fill();
</script>
I have found how I can do it by having a mouse over but it needs to be on click as they need to be able to then click on a link in the pop up area. The content of the pop up will come from a POST string set on the previous page.
I am a newbie to JavaScript although well experienced PHP programmer - can someone point me in the right direction please? Thank you