如何使图像可见? [英] How do I make an Image visible?

查看:89
本文介绍了如何使图像可见?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有以下代码:

< script>

LeftCurtain = new Image(midPoint, ht);

LeftCurtain.src =" images / black.gif";

LeftCurtain.left =" 0px";

LeftCurtain .top =" 0px";

LeftCurtain.visibility =" visible";

< / script>

什么都没有出现。不是在Firefox,Opera或IE7中。


谁能告诉我什么是错的?

解决方案

David Mark写道:


9月30日下午3:31,Cov写道:



< snip>


> LeftCurtain =新图像(midPoint,ht);



这两个参数定义在哪里?


> LeftCurtain.src =" images / black.gif";
LeftCurtain.left =" 0px" ;;



LeftCurtain.style.left =" 0";

无论单位如何,零都为零。此外,您需要将

位置属性设置为绝对,固定或相对(默认为静态。)


> LeftCurtain.top = QUOT; 0像素英寸;



这里也有同样的问题。



< snip>


这不是一个问题。不提供非零维度

单位可能是一个问题但是从零维度省略单位

不是必需的。


一个更重要的问题可能来自假设从新图像(...)返回的对象

将具有 - 样式 - 对象。

没有可以提供指导的规范,但从历史上看,

并不一定如此。


理查德。


9月30日晚上11点10分,David Mark< dmark.cins ... @ gmail.comwrote:


再次,听起来像一个非常差(或至少过时)的指南。

http://www.amazon.com/JavaScript-Def...1186893&sr=8-1


9月30日下午5:12,Richard Cornford < Rich ... @ litotes.demon.co.uk>

写道:


David Mark写道:
< blockquote class =post_quotes>
9月30日下午3:31,Cov写道:



< snip>


LeftCurtain = new Image(midPoint,ht);


这两个参数在哪里定义?


LeftCurtain.src =" images / black.gif";

LeftCurtain 。左= QUOT; 0像素英寸;


LeftCurtain.style.left =" 0";

零为零,无论是单元。此外,您需要将

位置属性设置为绝对,固定或相对(默认为静态。)


LeftCurtain.top =" 0px" ;;


此处存在同样的问题。



< snip>


不是这样的问题。不提供非零维度

单位可能有问题,但省略



你在那里失去了你,除非你在谈论老年人浏览器

typeof(el.style.top)==''number''。


来自零维度的单位


不是必需的。



不需要,提供一个似乎很愚蠢。有一点需要注意:Firefox返回0pt。 (对所有事物而言)当

单位不在作业时计算出的样式。这并不重要,因为在价值为零的任何情况下,显然都会忽略该单位。


>

一个更重要的问题可能是假设从新图像(...)返回的对象

将具有 - 样式 - 对象。有



对。这就是我告诉OP使用createElement的原因。


Hi,

I have the following code:
<script>
LeftCurtain=new Image(midPoint,ht);
LeftCurtain.src="images/black.gif";
LeftCurtain.left="0px";
LeftCurtain.top="0px";
LeftCurtain.visibility="visible";
</script>
Nothing appears. Not in Firefox, Opera or IE7.

Can anyone let me know what''s wrong?

解决方案

David Mark wrote:

On Sep 30, 3:31 pm, Cov wrote:

<snip>

> LeftCurtain=new Image(midPoint,ht);


Where are these two parameters defined?

> LeftCurtain.src="images/black.gif";
LeftCurtain.left="0px";


LeftCurtain.style.left = "0";
Zero is zero, regardless of the unit. Also, you need to set the
position property to absolute, fixed or relative (default is static.)

> LeftCurtain.top="0px";


Same problem here.

<snip>

Not that it is a problem as such. Not providing a non-zero dimension
with a unit can be a problem but omitting the unit from a zero dimension
is not required.

A more significant issue may follow from the assumption that the object
returned from - new Image( ... ) - would have a - style - object. There
is no specification that could provide guidance, but historically that
has not necessarily been the case.

Richard.


On Sep 30, 11:10 pm, David Mark <dmark.cins...@gmail.comwrote:

Again, sounds like a pretty poor (or at least outdated) guide.

http://www.amazon.com/JavaScript-Def...1186893&sr=8-1


On Sep 30, 5:12 pm, "Richard Cornford" <Rich...@litotes.demon.co.uk>
wrote:

David Mark wrote:

On Sep 30, 3:31 pm, Cov wrote:

<snip>

LeftCurtain=new Image(midPoint,ht);

Where are these two parameters defined?

LeftCurtain.src="images/black.gif";
LeftCurtain.left="0px";

LeftCurtain.style.left = "0";
Zero is zero, regardless of the unit. Also, you need to set the
position property to absolute, fixed or relative (default is static.)

LeftCurtain.top="0px";

Same problem here.


<snip>

Not that it is a problem as such. Not providing a non-zero dimension
with a unit can be a problem but omitting

You lost me there unless you are talking about older browsers where
typeof(el.style.top) == ''number''.

the unit from a zero dimension

is not required.

Not required, it just seems silly to me to provide one. One caveat is
that Firefox returns "0pt" (of all things) for the computed style when
the unit is left off the assignment. It doesn''t really matter as you
obviously ignore the unit in any case where the value is zero.

>
A more significant issue may follow from the assumption that the object
returned from - new Image( ... ) - would have a - style - object. There

Right. That''s why I told the OP to use createElement.


这篇关于如何使图像可见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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