简单指向文字显示内容实例
代码如下 | 复制代码 |
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>oec2003</title> <script language="JavaScript" type="text/JavaScript"> <!-- function toggle(targetid){ if (document.getElementById){ target=document.getElementById(targetid); if (target.style.display=="block"){ target.style.display="none"; } else { target.style.display="block"; } } } --> </script> <style type="text/css"> <!-- #div1{ background-color:#000000; height:400px; width:400px; display:none; } --> </style> </head> <body> |
经过连接时显示图片
代码如下 | 复制代码 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <script type="text/javascript"> var path = './'; //图片相对路径 function show(obj) { var name = obj.innerText; var sDiv = document.getElementById('img_' + name.split('.')[0]);//文件名自己判断 if (!sDiv) { sDiv = document.createElement("DIV"); sDiv.id = 'img_' + name.split('.')[0]; sDiv.style.position = 'absolute'; sDiv.style.top = obj.offsetTop + obj.offsetWidth + 'px'; sDiv.style.left = obj.offsetLeft +obj.offsetHeight + 'px'; sDiv.style.border = '1px red solid'; var img = document.createElement("img"); img.src = path + name; sDiv.appendChild(img); document.body.appendChild(sDiv); } sDiv.style.display = 'block'; } function f(obj) { var name = obj.innerText; var sDiv = document.getElementById('img_' + name.split('.')[0]);//文件名自己判断 if (sDiv) { sDiv.style.display = 'none'; } } </script> </head> <body> <div onmouseover="show(this)" onmouseout="f(this)" style="position:absolute;"> wait.gif </div> </body> </html> |
时间: 2024-09-13 00:55:16