Dans Posted December 23, 2012 Report Share Posted December 23, 2012 Eu tinha o seguinte código onde a imagem movia consoante o numero de cliques na seta:<!DOCTYPE html> <html> <head> <script> function clickright() { if(typeof(Storage)!=="undefined") { if (sessionStorage.clickright) { sessionStorage.clickright=Number(sessionStorage.clickright)+1; } else { sessionStorage.clickright=1; } document.getElementById("Giants").style.left = 250 + sessionStorage.clickright * 25 + "px"; } } function clickdown() { if(typeof(Storage)!=="undefined") { if (sessionStorage.clickdown) { sessionStorage.clickdown=Number(sessionStorage.clickdown)+1; } else { sessionStorage.clickdown=1; } document.getElementById("Giants").style.top = 250 + sessionStorage.clickdown * 25 + "px"; } } function clickup() { if(typeof(Storage)!=="undefined") { if (sessionStorage.clickup) { sessionStorage.clickup=Number(sessionStorage.clickup)+1; } else { sessionStorage.clickup=1; } document.getElementById("Giants").style.top = 250 - sessionStorage.clickup * 25 + "px"; } } function clickleft() { if(typeof(Storage)!=="undefined") { if (sessionStorage.clickleft) { sessionStorage.clickleft=Number(sessionStorage.clickleft)+1; } else { sessionStorage.clickleft=1; } document.getElementById("Giants").style.left = 250 - sessionStorage.clickleft * 25 + "px"; } } </script> </head> <body> <img src=http://icons.iconarchive.com/icons/evermor-design/nfl-helmets/128/Giants-icon.png style="height:50px;width:50px;position:absolute;top:250px;left:250px;" id="Giants"/> <img onclick="clickup()" id="up" onclick="clicky()" src="http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/arrow-up-icon.png" style="height:50px;width:50px;position:absolute;bottom:50px;left:50px"/> <img id="left" onclick="clickleft()" src="http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/arrow-left-icon.png" style="height:50px;width:50px;position:absolute;bottom:0px;left:0px;"/> <img id="down" onclick="clickdown()" src="http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/arrow-down-icon.png" style="height:50px;width:50px;position:absolute;bottom:0px;left:50px"/> <img id="right" onclick="clickright()" src="http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/arrow-right-icon.png" style="height:50px;width:50px;position:absolute;bottom:0px;left:100px"/> </body> </html> Mas ele tinha um bug: ele não via a diferença, por isso tive de alterar o código para: <script> function clickright() { if(typeof(Storage)!=="undefined") { if (sessionStorage.clickright) { sessionStorage.clickright=Number(sessionStorage.clickright)+1; } else { sessionStorage.clickright=1; } } } function clickdown() { if(typeof(Storage)!=="undefined") { if (sessionStorage.clickdown) { sessionStorage.clickdown=Number(sessionStorage.clickdown)+1; } else { sessionStorage.clickdown=1; } } } function clickup() { if(typeof(Storage)!=="undefined") { if (sessionStorage.clickup) { sessionStorage.clickup=Number(sessionStorage.clickup)+1; } else { sessionStorage.clickup=1; } } } function clickleft() { if(typeof(Storage)!=="undefined") { if (sessionStorage.clickleft) { sessionStorage.clickleft=Number(sessionStorage.clickleft)+1; } else { sessionStorage.clickleft=1; } } } { var x=(Number(sessionStorage.clickleft)-Number(sessionStorage.clickright))*25 + 250 var y=(Number(sessionStorage.clickdown)-Number(sessionStorage.clicktop))*25 + 250 document.getElementById("Giants").style.left = x document.getElementById("Giants").style.top = y </script> <body> <img src=http://icons.iconarchive.com/icons/evermor-design/nfl-helmets/128/Giants-icon.png style="height:50px;width:50px;position:absolute;top:250px;left:250px;" id="Giants"/> <img onclick="clickup()" id="up" onclick="clicky()" src="http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/arrow-up-icon.png" style="height:50px;width:50px;position:absolute;bottom:50px;left:50px"/> <img id="left" onclick="clickleft()" src="http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/arrow-left-icon.png" style="height:50px;width:50px;position:absolute;bottom:0px;left:0px;"/> <img id="down" onclick="clickdown()" src="http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/arrow-down-icon.png" style="height:50px;width:50px;position:absolute;bottom:0px;left:50px"/> <img id="right" onclick="clickright()" src="http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/arrow-right-icon.png" style="height:50px;width:50px;position:absolute;bottom:0px;left:100px"/> </body> </html>Mas neste deixou de funcionar o SessionStorage. Por favor ajudem. Quote Link to comment Share on other sites More sharing options...
Question
Dans
Eu tinha o seguinte código onde a imagem movia consoante o numero de cliques na seta:
Mas ele tinha um bug: ele não via a diferença, por isso tive de alterar o código para:Mas neste deixou de funcionar o SessionStorage. Por favor ajudem.
Link to comment
Share on other sites
0 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.