So what is the correct way can you provide me a simple example?
I'd appreciate it.
Thank you,
Bee

On Jul 22, 9:47 am, Derek Williams <[email protected]> wrote:
> Simon is correct, don't overload the images to store the state.
>
>
>
> On Tue, Jul 21, 2009 at 11:23 PM, Simon Fraser <[email protected]> wrote:
> > On Jul 21, 2009, at 2:39 pm, FloridaBee wrote:
>
> > I am trying to create a simple TicTacToe game. It works fine in
> > Firefox and IE but I have a problem with running it on iPhone. In my
> > validation method (look below) I am checking if the table cells
> > contains three same elements in rows/columns or cross. I also added
> > the alert() to check what url is used in different browsers and I
> > believe that the problem lays in document.getELementById
> > ().style.backgroundImage=url();.
>
> > In firefox the url is url(x.png) but the safari shows full path: url
> > (www.cs.uwf.edu/~jchudzyn/tic/x.png<http://www.cs.uwf.edu/%7Ejchudzyn/tic/x.png>
> > ).
> > Do you have to use full path for each image in the safari and iPhone?
> > Or there is another way to solve it?
> > Thank you for all answers,
> > Florida Bee
>
> > function checkLogic(){
> > var A=document.getElementById('A').style.backgroundImage;
> > var B=document.getElementById('B').style.backgroundImage;
> > var C=document.getElementById('C').style.backgroundImage;
> > var D=document.getElementById('D').style.backgroundImage;
> > var E=document.getElementById('E').style.backgroundImage;
> > var F=document.getElementById('F').style.backgroundImage;
> > var G=document.getElementById('G').style.backgroundImage;
> > var H=document.getElementById('H').style.backgroundImage;
> > var I=document.getElementById('I').style.backgroundImage;
> > var O="url(o.png)";
> > var X="url(x.png)";
>
> > alert(document.getElementById('A').style.backgroundImage);
> > if(A==X&&B==X&&C==X||D==X&&E==X&&F==X||G==X&&H==X&&I==X)
> > {
> >  check=1;
> >  winner='X';
> > }
>
> > This simple way to avoid this problem is to avoid using the style property
> > to store your game state. A cleaner way would be to keep a separate
> > JavaScript array to store the state of the 9 cells. On each click, you could
> > very easily run through this array and update the style on the table cell
> > using classes to assign the X or O background image.
>
> > Simon
>
> --
> Derek Williams
> Cell: 970.214.8928
> Home Office: 970.416.8996

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to