请...一些信息将非常感激。 [英] please... some info would be very appreciated.
问题描述
大家好,
首先让我告诉你我已经搜索了这个群组和互联网
并且无法找到答案我的问题。这可能是b $ b因为我不知道该找什么。我确实找到了我的问题
在1997年被这个小组中的一个人问过,但似乎没有人回答
他(我)的问题。作为最后的手段,我现在问我的问题。
我有一个处理许多div的功能。如何将该功能传递给div的
''对象'',以便我可以改变它的风格。
---
< div id =" layer1" style =" position:absolute; top:0; left:0;">< / div>
< script language =" javascript">
function move(divname){
divname.style.top = 100;
}
move(window.document .all.layer1);
< / script>
---
如果你可以给我任何帮助非常感谢!
Primus
Hello all,
First let me tell you that I have searched this group and the internet
and have not been able to find the answer to my problem. It is probably
because I don''t know what to look for. I did though find my question
asked in 1997 by a guy in this group but it seems that noone answered
his(my) question. As a very last resort I ask my question now.
I have a function to handle many divs. How do I pass that function the
''object'' of the div, so that I may change its style.
---
<div id="layer1" style="position:absolute;top:0;left:0;"></div>
<script language="javascript">
function move(divname){
divname.style.top = 100;
}
move(window.document.all.layer1);
</script>
---
If you could give me any help it would be very much appreciated!
Primus
推荐答案
primus写道:
大家好,
首先让我告诉你,我已经搜索了这个群组和互联网
并且无法找到我的问题的答案。这可能是因为我不知道该找什么。我确实找到了我的问题在1997年被这个小组中的一个人问过,但似乎没有人回答他(我)的问题。作为最后的手段,我现在问我的问题。
我有一个处理许多div的功能。如何将该功能传递给div的
''对象',以便我可以改变它的风格。
---
< div id ="层1" style =" position:absolute; top:0; left:0;">< / div>
< script language =" javascript">
function move(divname){
divname.style.top = 100;
}
move(window.document.all.layer1);
< / script>
- -
如果你能给我任何帮助,我将非常感谢!
Primus
Hello all,
First let me tell you that I have searched this group and the internet
and have not been able to find the answer to my problem. It is probably
because I don''t know what to look for. I did though find my question
asked in 1997 by a guy in this group but it seems that noone answered
his(my) question. As a very last resort I ask my question now.
I have a function to handle many divs. How do I pass that function the
''object'' of the div, so that I may change its style.
---
<div id="layer1" style="position:absolute;top:0;left:0;"></div>
<script language="javascript">
function move(divname){
divname.style.top = 100;
}
move(window.document.all.layer1);
</script>
---
If you could give me any help it would be very much appreciated!
Primus
单程是:
函数move(divname){
document.getElementById(divname).style.top = 100;
}
move(" layer1");
但这只适用于支持getElementById的浏览器
现在查看邮件新闻:美国****************** @ text.news.blueyonder.co。英国
Michael Winter在那里添加了一个漂亮的检查器。
那里,如果我理解正确,你会添加var getReferenceById ... ;代码
进入你的move()函数 - 将move(divname)改为move(id)或替换'id"
引用divname,以两者为准对你来说更容易 - 然后添加
if(getReferenceById&& getReferenceById.style)getReferenceById.style.top = 100 +''px''。
我不知道''px''哪里不起作用,但有一个浏览器无法正常工作
如果你省略'' px''另外。
Robi
one way is:
function move(divname){
document.getElementById(divname).style.top = 100;
}
move("layer1");
but that will only work with browsers that support getElementById
now check message news:US******************@text.news.blueyonder.co. uk
Michael Winter added a nifty checker in there.
there, if I understand it correctly, you would add the "var getReferenceById..." code
into your move() function - changing move(divname) to move(id) or replacing the "id"
references to "divname", whichever is easier for you - and then add
if(getReferenceById && getReferenceById.style) getReferenceById.style.top = 100+''px''.
I''m not sure where ''px'' doesn''t work, but there is a browser that doesn''t work right
if you omit the ''px'' addition.
Robi
primus写道:
大家好,
你好,
作为最后的手段我现在问我的问题。
我有一个处理很多div的功能。我如何将该函数传递给div的
''对象',以便我可以改变它的风格。
Hello all,
Hello alone,
As a very last resort I ask my question now.
I have a function to handle many divs. How do I pass that function the
''object'' of the div, so that I may change its style.
< html>
< style type =" text / css">
* {text-align:center}
< / style>
< script type =" text / javascript">
函数move(divname,left,top){
if(document.getElementById ){
var d = document.getElementById(divname).style;
if(top)d.top = top +''px'';
if(left)d.left = left +''px'';
}
}
< / script>
< div id =" layer1"
style =" position:absolute; top:0; left:0; width:200px; border:1px solid red">
< h2> DIV 1移动< / h2>
< p>< a href =" javascript :move(''layer1'',100,50);">
从window-top = 50移动layer1,从window-left = 100
< / a>
< p>< a href =" javascript :move(''layer2'',320,20); ">
将layer2移动到window-top = 50,window-left = 320
< / a>
< / div>
< div id =" layer2" style =" position:absolute; top:0;
left:-300; width:200px; border:1px solid red">
< h2> DIV 2移动< / h2>
< / div>
< / html>
-
Stephane Moriaux et son [moins] vieux Mac
<html>
<style type="text/css">
* { text-align: center }
</style>
<script type="text/javascript">
function move(divname,left,top){
if(document.getElementById) {
var d = document.getElementById(divname).style;
if(top) d.top = top+''px'';
if(left) d.left = left+''px'';
}
}
</script>
<div id="layer1"
style="position:absolute;top:0;left:0;width:200px; border:1px solid red">
<h2>DIV 1 to move</h2>
<p><a href="javascript:move(''layer1'',100,50);">
move layer1 from window-top = 50, from window-left = 100
</a>
<p><a href="javascript:move(''layer2'',320,20);">
move layer2 to window-top = 50, and window-left = 320
</a>
</div>
<div id="layer2" style="position:absolute;top:0;
left:-300;width:200px;border:1px solid red">
<h2>DIV 2 to move</h2>
</div>
</html>
--
Stephane Moriaux et son [moins] vieux Mac
谢谢!谢谢!谢谢!
我的头痛现在消失了!我不知道那么容易。
再次谢谢你,
Primus
Thank you! Thank you! Thank you!
My headache is gone now! I didn''t know it was that easy.
Again Thank You,
Primus
这篇关于请...一些信息将非常感激。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!