如何动态地生成一个<div>? 难道你的程序不是在加载的时候被执行的吗?加载的时候,只要使用document.write()就行了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不是的。原来的程序是可以用,但是不好用,太多的参数。于是,我就想做一个类来实现原来的功能。这样,用户可以在代码中通过new和delete来创建对象,来调用我的日历。顺便问一下,在JavaScript中如何得到当前的鼠标的位置? 获得鼠标位置:event.clineX;ecent.clientY这是相对于当前窗口的相对位置绝对位置还要加上scrollTop;scrollLeft 不好意思,是我没有说清楚。我不是想在事件的响应函数中得到鼠标的位置,我是想在任意的javascript代码中得到鼠标的位置。 将你的document.openg改成***.innerHTML = "";就可以实现注意***是一个HTML元素的名字,要选择一个适当的HTML元素来实现,并且这个HTML元素要有innerHTML这个属性。得到鼠标的位置不难<HTML><HEAD><META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"><TITLE>explain text</TITLE></HEAD><script>function getposition(a){ show.value=a; show.size=show.value.length*2-1; exp.style.top=event.clientY+10; **************这两行就是得到鼠标位置的代码 exp.style.left=event.clientX+10; ************** exp.style.display="";}function clearposi(){ exp.style.display="None";}</script><BODY><img src="cat3.gif" onmousemove="getposition('This is a cat!')" onmouseout="clearposi()" style="cursor=hand;filter:alpha(opacity=40)" width=100 height=100><img src="redarrow.gif" onmousemove="getposition('happy!!!')" onmouseout="clearposi()" style="cursor=hand"><img src="cat3.gif" onmousemove="getposition('猫猫猫猫猫猫猫猫猫猫')" onmouseout="clearposi()" width=300 height=300 style="cursor=hand"><a href="#" onmousemove="getposition('log in.')" onmouseout="clearposi()">test</a><div id=exp style="position:absolute;left:100;top:10;display:None"><input type=text name=show style="background-color: #C0C0C0; color: #000000; border-style: solid; border-color: black"></div><input type=button value="删除" style="background-color: #C0C0C0; color: #000000; border-style: solid; border-color: black; width=40; height=19"></BODY></HTML> runmin说的正是问题的结症所在,如果我可以要求页面中有这样的HTML元素,我也就不问这个问题了。我的问题就是如何在发生特定的事件时,在页面中动态生成这样的元素。 <script language=javascript> var temp=""; temp+="<div style=\"position=absolution id=0000111></div>"; document.write(temp); </script> 具体的单词请查相关资料,记不清了 哈哈。我已经实现我要的功能了。各位的方法只能在“下载”时运行的javascript代码中有效。我的代码是这样的, document.body.innerHTML += "<div id=" + theDivId + " style=\"position:absolute;left:100;top:10; visibility: visible\"> <input type=text name=helptext value=\"test\"></div> "; 呵呵,这样的代码在“下载”时运行的代码中时无效的。 popup.js 使用 javascript方法调用 javascript清空一个div中所有控件的值 js报错 对象不支持此属性或方法 如何利用正则表达式替换后得到如下内容 出售网站 急请问,javascript的显示问题。 请帮忙! parent.window.opener.ifraName.frameElement.style.display="";不可以? 一个白痴式却又解决不了的问题 一个关于正则的问题: 请大家看看,版主帮忙!! 怎么样用OnClick来把一个List里选的值加在另一个List里?
这是相对于当前窗口的相对位置
绝对位置还要加上scrollTop;scrollLeft
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>explain text</TITLE>
</HEAD>
<script>function getposition(a)
{
show.value=a;
show.size=show.value.length*2-1;
exp.style.top=event.clientY+10; **************这两行就是得到鼠标位置的代码
exp.style.left=event.clientX+10; **************
exp.style.display="";
}function clearposi()
{
exp.style.display="None";
}</script>
<BODY><img src="cat3.gif" onmousemove="getposition('This is a cat!')" onmouseout="clearposi()" style="cursor=hand;filter:alpha(opacity=40)" width=100 height=100>
<img src="redarrow.gif" onmousemove="getposition('happy!!!')" onmouseout="clearposi()" style="cursor=hand">
<img src="cat3.gif" onmousemove="getposition('猫猫猫猫猫猫猫猫猫猫')" onmouseout="clearposi()" width=300 height=300 style="cursor=hand">
<a href="#" onmousemove="getposition('log in.')" onmouseout="clearposi()">test</a>
<div id=exp style="position:absolute;left:100;top:10;display:None">
<input type=text name=show style="background-color: #C0C0C0; color: #000000; border-style: solid; border-color: black">
</div>
<input type=button value="删除" style="background-color: #C0C0C0; color: #000000; border-style: solid; border-color: black; width=40; height=19">
</BODY>
</HTML>
<script language=javascript>
var temp="";
temp+="<div style=\"position=absolution id=0000111></div>";
document.write(temp);
</script>
具体的单词请查相关资料,记不清了
document.body.innerHTML +=
"<div id=" + theDivId +
" style=\"position:absolute;left:100;top:10; visibility: visible\">
<input type=text name=helptext value=\"test\"></div>
";
呵呵,这样的代码在“下载”时运行的代码中时无效的。