Firefox和Chrome无法正确更新GIF图像的位置 [英] Firefox and Chrome not updating position of GIF images properly

查看:77
本文介绍了Firefox和Chrome无法正确更新GIF图像的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有人。自从我上次访问以来已经有一段时间了。


程序的简短说明:使用DHTML / Javascript完全构建html元素的棋盘游戏。 Board由html表构成,每个表格单元格都有一个图像(表格一起形成一个地图/板)。玩家(2-4)每个都有他们自己的棋子,使用z-index漂浮在棋盘上(他们是GIF图像)。


我去年秋天实际上做了这个程序,它的工作原理除了在启动时将GIF图像(玩家的棋子)放置在棋盘上时,Firefox和谷歌Chrome有一些奇怪的行为。一些令人耳目一新的移动棋子总能正常工作后,它们会进入正确的位置。就在启动时(除非页面已经刷新),pawn将从中上部开始,而不是在它们的起始位置。顺便说一句,这在IE 7,IE 8和Opera中运行得非常好。


这是我在开始时设置玩家典当起始位置的代码。

展开 | 选择 | Wrap | 行号

解决方案

什么时候执行代码?在页面的onload处理程序?


亲切的问候


实际上没有。有一个html页面,其中包含玩家姓名的形式和带规则的游戏描述。所有在div元素中的内容将被游戏表(和其他游戏相关的东西)通过从表单调用的Javascript函数tarkista()替换。


这是从html页面形式调用的函数(验证和构建游戏表也会创建新的Peli对象(Game对象)):

展开 | 选择 | Wrap | >行号


查看firefox-error控制台或使用firbebug for firefox查看是否可以使用当前代码可靠地检索节点...否则从页面的onload-handler调用代码,这应该可以解决问题...


亲切的问候


Hey all. It''s been a while since I last visited.

Short description of program: Board game which''s html elements are fully constructed using DHTML/Javascript. Board is constructed of html table, and each table cell has one image (together the table forms a map/board). Players (2-4) each have their own pawns that float over the board using z-index (they are GIF-images).

I actually did this program last fall and it works fine and dandy except Firefox and Google Chrome have a bit odd behaviour when it comes to placing GIF images (players'' pawns) on the board on startup. They get into proper position after some refreshing and moving pawns works properly always. Just at the startup (unless page has been refreshed) will the pawn start at upper middle and not in their starting positions. This works perfectly fine in IE 7, IE 8 and Opera by the way.

Here is the code where I set the starting position of players'' pawns upon starting.

Expand|Select|Wrap|Line Numbers

解决方案

when is the code executed? in the page''s onload handler?

kind regards


Actually no. There is a html page which has a form for player names and description of game with rules. All that is inside div element which''s contents will be replaced by gametable (and other game related stuff) via Javascript function tarkista() that is called from form.

This is function that is called from form of html page (validates and builds gametable also creates new Peli object (Game object)):

Expand|Select|Wrap|Line Numbers


have a look at the firefox-error console or use firbebug for firefox to see whether the node could be retrieved reliably with your current code ... otherwise call the code from the onload-handler of the page this should solve the problem ...

kind regards


这篇关于Firefox和Chrome无法正确更新GIF图像的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆