<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD><BODY>
<script language="JavaScript">
<!--
//图片按比例缩放
var flag=false;
function DrawImage(ImgD){
var image=new Image();
var iwidth = 80; //定义允许图片宽度
var iheight = 80; //定义允许图片高度
image.src=ImgD.src;
if(image.width>0 && image.height>0&&flag==false){
if(image.width/image.height>= iwidth/iheight){
if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
}
} function ref(ImgD)
{
flag =!flag;
if(flag)
{
var image=new Image();
var iwidth = 80; //定义允许图片宽度
var iheight = 80; //定义允许图片高度
image.src=ImgD.src;
ImgD.width=image.width;
ImgD.height=image.height;
}
else
{
DrawImage(ImgD)
}
}
//-->
</script><img src="http://community.csdn.net/ADV/Images/csdn120x360.GIF" onload = "DrawImage(this)" onclick="ref(this)">
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD><BODY>
<script language="JavaScript">
<!--
//图片按比例缩放
var flag=false;
function DrawImage(ImgD){
var image=new Image();
var iwidth = 80; //定义允许图片宽度
var iheight = 80; //定义允许图片高度
image.src=ImgD.src;
if(image.width>0 && image.height>0&&flag==false){
if(image.width/image.height>= iwidth/iheight){
if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
}
} function ref(ImgD)
{
flag =!flag;
if(flag)
{
var image=new Image();
var iwidth = 80; //定义允许图片宽度
var iheight = 80; //定义允许图片高度
image.src=ImgD.src;
ImgD.width=image.width;
ImgD.height=image.height;
}
else
{
DrawImage(ImgD)
}
}
//-->
</script><img src="http://community.csdn.net/ADV/Images/csdn120x360.GIF" onload = "DrawImage(this)" onclick="ref(this)">
</BODY>
</HTML>
解决方案 »
- DWR异常:ERROR [org.directwebremoting.impl.DefaultCreatorManager] - <Illegal identifier: ''>
- 页面中框架值传递问题,应该很简单
- 很简单的js,在线等,马上给分
- onbeforeunload时设为首页如何实现?
- 关于页面自动添加控件的问题,急
- 在线求救,能否得到表格中单元格的列号?
- (菜鸟一问~!)怎么生成 *.js文件并在jsp中直接调用*.js文件?
- 请教JavaScript高手,如何动态添加表格行 并给相应行中的文本框动态命名?
- 有什么辦法讓瀏覽器地址欄顯示指定的地址而不是自動顯示的地址?
- highcharts 一个页面动态绘制多个图
- 如何根据下拉框的文本值确定下拉框的索引?
- 一个javascript的问题
而页面中其它部分的图片不需要调用这个方法进行处理,所以我就需要动态的向content所代表代码中的<img>标签中写入方法调用。
我想问的是怎样能这样动态的写入
Dim re, strMatches, strMatch, tmpStr1, tmpStr2
Set re=new RegExp
re.IgnoreCase =True
re.Global=True re.Pattern="\[img\](.*?)\[\/img\]"
Set strMatches=re.Execute(strContent)
For Each strMatch In strMatches
tmpStr1=CheckLinkStr(strMatch.SubMatches(0))
strContent=Replace(strContent,strMatch.Value,"<img src="""&tmpStr1&""" border=""0"" onload=""javascript:DrawImage(this);"" alt=""按此在新窗口打开图片"" onmouseover=""this.style.cursor='hand';"" onclick=""window.open(this.src);"" />")
Next
Set strMatches=Nothing re.Pattern="\[img=(left|right|center|absmiddle)\](.*?)\[\/img\]"
Set strMatches=re.Execute(strContent)
For Each strMatch In strMatches
tmpStr1=strMatch.SubMatches(0)
tmpStr2=CheckLinkStr(strMatch.SubMatches(1))
strContent=Replace(strContent,strMatch.Value,"<img src="""&tmpStr2&""" align="""&tmpStr1&""" onload=""javascript:DrawImage(this);"" border=""0"" alt=""按此在新窗口打开图片"" onmouseover=""this.style.cursor='hand';"" onclick=""window.open(this.src);"" />")
Next
Set strMatches=Nothing
%>