stillm32 2010-04-19 03:45:21
我有一个代码如下:<img src="image/1.jpg">怎么不用<a>标签实现鼠标点击跳转?在360安全浏览器上运行的,谢了!
...全文
511 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
踏雪浪人 2010-04-19
  • 打赏
  • 举报
回复
根据你的js,你这样做,link是地址,target是指你是否在本页打开等信息

<div id="photo" style="width:540px;height:150px;border:1px solid red; background-color:White">
<img src="./1.jpg" link="http://www.baidu.com" target="_blank">
<img src="./1.jpg" link="http://www.google.com" target="_blank">
<img src="./1.jpg" link="http://www.sina.com.cn" target="_blank">
<img src="./1.jpg" link="http://www.zhcw.com" target="_blank">
<img src="./1.jpg" link="http://www.qq.com" target="_blank">
</div>
stillm32 2010-04-19
  • 打赏
  • 举报
回复
不好意思是我没说清楚,以上方法我试过,不行。具体代码是这样的:
<html>
<head>
<title>JavaScript实现图片旋转构成3D圆环代码</title>
<script language="javascript">
window.onload=function(){
var rt=new imgRound("photo",120,90,260,20,250,0.01);//参数分别表示控件id,单个图片的长和高,空间旋转的原点坐标,旋转半径,旋转速度
setInterval(function(){rt.roundMove()},20);
}
function imgRound(id,w,h,x,y,r,dv,rh,ah){
if (ah==undefined) ah=1;
if (rh==undefined) rh=10;
var dv=dv*ah; //旋转速度
var pi=3.1415926575;
var d=pi/2;
var pd=Math.asin(w/2/r);
var smove=true;
var imgArr=new Array();
var objectId=id;
var o=document.getElementById(objectId);
o.style.position="relative";
var arrimg=o.getElementsByTagName("img");
var pn=arrimg.length; //图片数量
var ed=pi*2/pn;
for (n=0;n<arrimg.length;n++){
var lk=arrimg[n].getAttribute("link");
if (lk!=null) arrimg[n].setAttribute("title",lk)
arrimg[n].onclick=function(){
if (this.getAttribute("link")!=null){
if (this.getAttribute("target")!="_blank") window.location=(this.getAttribute("link"))
else window.open(this.getAttribute("link"))
}
}
arrimg[n].onmouseout=function()
{
smove=true;
}
arrimg[n].onmouseover=function()
{
smove=false;
}
arrimg[n].style.position="absolute";
imgArr.push(arrimg[n]);
}
this.roundMove=function(){
for (n=0;n<=pn-1;n++){
var o=imgArr[n];
var ta=Math.sin(d+ed*n),strFilter;
if (ta<0) o.style.left=Math.cos(d+ed*n-pd)*r+x+"px";
else o.style.left=Math.cos(d+ed*n+pd)*r+x+"px";
o.style.top=ta*rh+rh+y+"px";
var zoom=Math.abs(Math.sin((d+ed*n)/2+pi/4))*0.5+0.5;
o.style.width=Math.abs(Math.cos(d+ed*n+pd)-Math.cos(d+ed*n-pd))*zoom*r+"px";
o.style.height=zoom*h+"px";
if (ta<0) {ta=(ta+1)*80+20;o.style.zIndex=0;}
else {ta=100;o.style.zIndex=1}
if (o.style.zIndex<=0) strFilter="FlipH(enabled:true)"
else strFilter="FlipH(enabled:false)";
strFilter=strFilter+" alpha(opacity="+ta+")";
o.style.opacity=ta/100;
o.style.filter=strFilter;
}
if (smove){
d=d+dv;
}
}
}
</script>
</head>
<body>
<div id="photo" style="width:540px;height:150px;border:1px solid red; background-color:White">
<img src="image/1.jpg" onclick="location='http://www.baidu.com'">
<img src="image/1.jpg" onclick="location='http://www.baidu.com'">
<img src="image/1.jpg" onclick="location='http://www.baidu.com'">
<img src="image/1.jpg" onclick="location='http://www.baidu.com'">
<img src="image/1.jpg" onclick="location='http://www.baidu.com'">
</div>
</body>
</html>
shichao102471077 2010-04-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 knifewei 的回复:]
给图片加onclick事件

方法一:onclick="javascript:window.location.href='http://www.52banmian.cn'"

方法二:onclick="location='http://www.52banmian.cn'"

方法三:onclick="window.location.href='http://www.52banmian……
[/Quote]

同意
shichao102471077 2010-04-19
  • 打赏
  • 举报
回复
<img src="image/1.jpg" onclick="location'你要打开的网站'">
knifewei 2010-04-19
  • 打赏
  • 举报
回复
给图片加onclick事件

方法一:onclick="javascript:window.location.href='http://www.52banmian.cn'"

方法二:onclick="location='http://www.52banmian.cn'"

方法三:onclick="window.location.href='http://www.52banmian.cn/webdesign/20091121150050.html'"
jqm a标签不跳转 在用了jqm后,基本上所有与按钮跳转有关的都是用a标签来做的href="#" class="ui-btn"> href="#" data-rel="button">这两个都可以将a标签变成按钮,但是在点击跳转的时候,按钮点击了跳转不了,一般加上data-ajax=”false”可以做到及时跳转, jqm 页面跳转不刷新 经常会遇到点击
1.href="#"> 页面将跳转到当前页面的页头。 2. href="#none" >点击时,会跳转到id为none 的元素的位置(如果存在),即锚链接。 3.href="###" > 在ie11和chrome中不再会跳转到当前页的页头,但是URL依然会改变,同时也会出发hash

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧