标题:程序什么地方出错了?
只看楼主
lisir123
Rank: 1
等 级:新手上路
帖 子:215
专家分:0
注 册:2005-12-16
结帖率:100%
 问题点数:0 回复次数:6 
程序什么地方出错了?

<SCRIPT language=javascript>
function showing() {
newX = window.event.x + document.body.scrollLeft
newY = window.event.y + document.body.scrollTop
menu = document.all.itemopen
if ( menu.style.display == ""){
menu.style.display = "none" }
else {
menu.style.display = ""}

menu.style.pixelLeft = newX + 50
menu.style.pixelTop = newY

document.write("<table width='100' height='100' border='0' cellpadding='0' cellspacing='0' class='box' id='itemopen' style='display:none'>")
document.write("<tr><td><img src='showing.asp' width='100' height='100'></td></tr> ")

document.write("</table>")
}
</SCRIPT>

[此贴子已经被作者于2006-1-10 11:19:44编辑过]

搜索更多相关主题的帖子: javascript function border 
2006-01-10 11:18
dpxdpx
Rank: 1
等 级:新手上路
帖 子:230
专家分:0
注 册:2005-11-22
得分:0 
哪里错了?

从不懂到懂点点到有点懂到懂点了到想搞懂更多到问题更多了到不懂的更多了到编程论坛请教大家来了!
2006-01-10 11:24
lisir123
Rank: 1
等 级:新手上路
帖 子:215
专家分:0
注 册:2005-12-16
得分:0 

下面是我全部的代码: 我想实现当点击表格中间一行是,调用showing()函数,问题是,调用函数以后,图片也出来了,但是把原来的表格给覆盖掉了.这是为什么?
test.asp
*****************************************
<html>
<head>
<title>图片显示</title>
<style type="text/css">
<!--
body { font-family: "宋体"; font-size: 9pt; margin-top: 0px; margin-left: 0px; margin-right: 0px}
A { COLOR:black; FONT-SIZE: 9pt; FONT-WEIGHT: 400; TEXT-DECORATION: none }
A:hover { COLOR: red; FONT-SIZE: 9pt; FONT-WEIGHT: 400; TEXT-DECORATION: underline }
a:active { font: 9pt "宋体"; cursor: hand; color: #FF0033 }
a.cc:hover { font: 9pt "宋体"; cursor: hand; color: #FF0033}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#fef4d9">
<SCRIPT language=javascript>
function showing() {
document.write("<style>")
document.write(".box { font: 9pt '宋体'; position: absolute; background: #ffffff }")
document.write("</style>")
document.write("<table width='100' height='100' border='0' cellpadding='0' cellspacing='0' class='box' id='itemopen' style='display:none'>")
document.write("<tr><td><img src='showing.asp' width='100' height='100'></td></tr> ")

document.write("</table>")
newX = window.event.x + document.body.scrollLeft
newY = window.event.y + document.body.scrollTop
menu = document.all.itemopen
if ( menu.style.display == ""){
menu.style.display = "none" }
else {
menu.style.display = ""}

menu.style.pixelLeft = newX + 50
menu.style.pixelTop = newY


}
</SCRIPT>
<table width="44%" height="173" border="1" align="center" cellpadding="1" cellspacing="1">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td align="center" onClick="showing()">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>

</body>
</html>
******************************************************
showing.asp
*****************************************************
<!--#include file="share/Conn.asp" -->
<%
set rec=server.createobject("ADODB.recordset")
sql="select picture from kqxxb where mkid=100502"
rec.open sql,conn
Response.ContentType="image/*"
Response.BinaryWrite rec("picture").getChunk(7500000)
rec.close
set rec=nothing
set conn=nothing
%>
showing.asp是为了实现从数据中调用二进制图片. 测试是可以找个图片代替

[此贴子已经被作者于2006-1-10 11:38:50编辑过]

2006-01-10 11:37
rainic
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2367
专家分:0
注 册:2005-8-9
得分:0 
这想这个可以帮到你吧
[CODE]<html>
<head>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="form1">
<input name="attach" type="file" onchange="javascript:ShowImg(this.value);" onKeyDown="javascript:return(false);" size="20">
<script language="JavaScript">
function ShowImg(src)
{
document.getElementById("imgDiv").innerHTML="图片预览:<br><img id='imgObj' onerror='javascript:GetError()' onload='javascript:GetSize()' src='file:///" + src + "'>";
}
function GetSize()
{
var width,height;
var imgObj=document.getElementById("imgObj");
width=imgObj.width;
height=imgObj.height;
document.getElementById("err_msg").innerHTML="图片大小(宽×高):<font color=red>" + width + "×" + height + "</font>";
if(width>164){
imgObj.width=164;
imgObj.height=imgObj.height/(imgObj.width/164);
}
}
function GetError()
{
document.getElementById("err_msg").innerHTML="图片大小(宽×高):<font color=red>NaN</font>";
document.getElementById("imgDiv").innerHTML="";
document.getElementById("err_msg").innerHTML="图片文件不存在或格式错误!"
}
</script>
<div id="imgDiv" align="center"></div>
<div id="err_msg" align="center"></div>
</form>
</body>
</html>[/CODE]

2006-01-10 11:42
lisir123
Rank: 1
等 级:新手上路
帖 子:215
专家分:0
注 册:2005-12-16
得分:0 
以下是引用rainic在2006-1-10 11:42:00的发言:
这想这个可以帮到你吧
[CODE]<html>
<head>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="form1">
<input name="attach" type="file" onchange="javascript:ShowImg(this.value);" onKeyDown="javascript:return(false);" size="20">
<script language="JavaScript">
function ShowImg(src)
{
document.getElementById("imgDiv").innerHTML="图片预览:<br><img id='imgObj' onerror='javascript:GetError()' onload='javascript:GetSize()' src='file:///" + src + "'>";
}
function GetSize()
{
var width,height;
var imgObj=document.getElementById("imgObj");
width=imgObj.width;
height=imgObj.height;
document.getElementById("err_msg").innerHTML="图片大小(宽×高):<font color=red>" + width + "×" + height + "</font>";
if(width>164){
imgObj.width=164;
imgObj.height=imgObj.height/(imgObj.width/164);
}
}
function GetError()
{
document.getElementById("err_msg").innerHTML="图片大小(宽×高):<font color=red>NaN</font>";
document.getElementById("imgDiv").innerHTML="";
document.getElementById("err_msg").innerHTML="图片文件不存在或格式错误!"
}
</script>
<div id="imgDiv" align="center"></div>
<div id="err_msg" align="center"></div>
</form>
</body>
</html>[/CODE]

还是没弄明白我的意思,我现在已经把图片以二进制形式传到sql数据中了,现在我要读取这些图片,读取的方式是,当点击中间一行时,调用showing函数,使图片以宽100,高100大小显示,再次点击中间行,图片消失

2006-01-10 11:53
rainic
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2367
专家分:0
注 册:2005-8-9
得分:0 
知道啊,你仔细研究一下你错在哪里,你JS代码和我发给你的有什么不同

2006-01-10 11:57
lisir123
Rank: 1
等 级:新手上路
帖 子:215
专家分:0
注 册:2005-12-16
得分:0 
谢谢了,我在实施
2006-01-10 12:00



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-42221-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015731 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved