5

I need to wait for a certain object to load while it is hidden. But what appears to be happening, is that it only loads without the display:none;

I'm using jQuery, and I tried putting the .load on the object to call a function when it loads, but seems that it will not load, because it's hidden.

Is there a way of 'forcing' the load of the Object, or, another way to 'hide' but still loading?

How to do it correcly:

use visibility: hidden instead of display: none

as explained here: http://www.w3.org/TR/SVG/painting.html#VisibilityProperty

When the ‘display’ property is set to none, then the given element does not become part of the rendering tree. With ‘visibility’ set to hidden, however, processing occurs as if the element were part of the rendering tree


Prevent Javascript Injection

I have a website that uses a captcha. http://blog.lukeblackamore.com/2009/10/sexy-captcha-new-drag-and-drop-captcha.html But the problem is that it can be cracked easily using Javascript injection through:

var res=document.querySelector(".targetWrapper .target").style["background-    position"].match(/\d+/);
[].map.call(document.querySelectorAll(".draggable"),function(a){
if(a.style["background-position"].match(/\d+/)[0]==res){
return document.querySelector(".captchaAnswer").value=a.id
}
});

How can I prevent this?

4

3 回答 3

3

如何正确操作:

使用visibility: hidden而不是display: none

如此处所述:http: //www.w3.org/TR/SVG/painting.html#VisibilityProperty

当 'display' 属性设置为 none 时,给定元素不会成为渲染树的一部分。但是,将“可见性”设置为隐藏时,会像元素是渲染树的一部分一样进行处理

感谢@SomeKittens

于 2012-08-05T04:52:54.977 回答
3

将其加载到屏幕外,style="position:absolute;left:100000px"

于 2012-08-05T04:29:26.513 回答
2

It seems that an SVG will not be rendered if the element is set to display:none. It's possible to load every element individually with JS as shown in this answer.

于 2012-08-05T04:46:28.477 回答