Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
515 views
in Technique[技术] by (71.8m points)

javascript - 在iOS上使用Chrome不会触发图片onLoad事件(Image onLoad event is not triggered using Chrome on iOS)

I am using Scala.js and d3.js ( scala-js-d3 ) to draw an SVG in a web application.(我正在使用Scala.jsd3.jsscala-js-d3 )在Web应用程序中绘制SVG。)

The problem I have is that for my background image the load event is not triggered when using Chrome on iOS (iPhone).(我的问题是,对于iOS背景图像,在iOS(iPhone)上使用Chrome时不会触发load事件。) It does trigger when using Chrome on Windows.(在Windows上使用Chrome时会触发。) The image itself is visible on all platforms.(图像本身在所有平台上都是可见的。) Here is how I add the image:(这是我添加图像的方式:) d3.select("#backgroundImg") .append("image") .attr("id", "graphBackgroundImage") .attr("width", "1954px") .attr("height", "1532px") .attr("xlink:href", "img/maps/map.png") // TODO this load event does not trigger on iOS! .on("load", (_: EventTarget) => { println("image loaded") } : Unit) .on("error", (_: EventTarget) => { prinltn("an error has occured") } : Unit) On Windows this creates the following svg dom element (and everything works as expected):(在Windows上,这将创建以下svg dom元素(并且所有操作均按预期方式进行):) <g id="backgroundImg"> <image id="graphBackgroundImage" width="1954px" height="1532px" xlink:href="img/maps/map.png"></image> </g> It is a bit hard to debug on the iPhone I have, so this is all I found out so far.(在我拥有的iPhone上调试起来有点困难,所以到目前为止,这是我发现的全部。) I just know that image loaded is not logged when using Chrome on iOS (there is also no an error has occured log).(我只知道在iOS上使用Chrome时未记录image loaded (日志也没有an error has occured )。)   ask by Florian Baierl translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There is a similar topic (minus the scala JS) about this, here is the link: Topic One(有一个类似的话题(减去scala JS),这是链接: 话题一)

Here is another one that may help: Topic Two(这可能会有所帮助: 主题二) The solution ended up being that they had "css-properties specifying 'pointer events'"(该解决方案最终是因为它们具有“指定'指针事件'的css属性”) Can you send your url for review.(您可以发送您的网址进行审核。) I think I may have another idea if neither of the two links help, but I need to see more of the code.(我想如果两个链接都没有帮助,我可能会有另一个想法,但是我需要查看更多代码。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...