关于javascript: void(0)的有关问题!
关于javascript: void(0)的问题!!
单位主页一个图片轮显的代码,两张图片!在点击1或者2的时候IE就自动新建窗口,并在IE地址栏中显示“javascript: void(0)”这个!!但是用360浏览器在极速模式下就没有这种情况!我在百度里查了一下,没找到相关的解决办法,求各位大神指点一下!谢谢了!!代码如下:
<script type="text/javascript">
<!--
var o = new Rotate(193, 93, "zgsw");
o.addImg([{url:"images/zgsw.png", link: "http://192.168.10.6/home/zgsw/"},{url:"images/zjlxx1.jpg", link: "http://192.168.10.6/home/xxwhjd/"}]);
o.show();
function Rotate(width, height, zgsw, timeout)
{
var isIE = navigator.appName == "Microsoft Internet Exploer";
var isFF = /Firefox/i.test(navigator.userAgent);
this.imgInfo = [];
this.width = parseInt(width);
this.height = parseInt(height);
this.box = $(zgsw);
this.timeout = timeout || 30000;
this.index = 0;
this.oImg = null;
this.timer = null;
this.innerbox = "asfman_" + uniqueID(6);
this.order = "asfman_" + uniqueID(6);
this.img = "asfman_" + uniqueID(6);
this.template = "<div id='" + this.innerbox + "'>\r\n" + "<div id='" + this.order + "'>\r\n{order}\r\n<div style='clear: both'></div>\r\n</div>";
//add css
var styleCss = "#" + this.innerbox + "{overflow: hidden; position: relative; width: " + this.width + "px; height: " + this.height + "px;}\r\n" +
"#" + this.order + "{position: absolute; right: 5px; bottom: 5px;}\r\n" +
"#" + this.order + " a{width: 16px; line-height: 16px; height: 16px; text-align: center; margin: 3px 3px 0 3px; border: 1px solid #c2c; float: left;}\r\n" + "#" + this.order + " a:link, #" + this.order + " a:visited{color:#000; text-decoration: none; background: #fff;}\r\n"+
"#" + this.order + " a:hover{background: #FF840C; text-decoration:none; }\r\n" +
"#" + this.innerbox + " img{border: 0; width: " + this.width + "px; height: " + this.height + "px;}\r\n";
function uniqueID(n)
{
var str="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
for(var ret = "", i = 0; i < n; i++)
{
ret += str.charAt(Math.floor(Math.random()*62));
}
return ret;
};
void function(cssText, doc)
{
doc = doc || document;
var oStyle = doc.createElement("style");
oStyle.type = "text/css";
if(oStyle.styleSheet)
{
oStyle.styleSheet.cssText = cssText;
}
else
{
oStyle.appendChild(doc.createTextNode(cssText));
}
doc.getElementsByTagName("head")[0].appendChild(oStyle);
}(styleCss);
function $(str){return document.getElementById(str);};
function addListener(o, type, fn)
{
var func = function()
{
return function(){fn.call(o);}
}();
if(isIE)
{
o.attachEvent("on" + type, func);
}
else if(isFF)
{
o.addEventListener(type, func, false);
}else{
o["on" + type] = func;
}
return func;
}
if(Rotate.initialize == undefined)
{
Rotate.prototype.addImg = function(obj)
{//{url: imgUrl, link: linkUrl, alt: alt, txt: txt}
if(obj)
{
if(obj.constructor == Array)
{
for(var i = 0, l = obj.length; i < l; i++)
{
this.imgInfo.push(obj);
}
}else
this.imgInfo.push(obj);
}
}
Rotate.prototype.show = function()
{
var _this = this;
var order = "";
for(var i = 1, l = this.imgInfo.length; i <= l; i++)
{
order += "<a href='javascript: void(0)'>" + i + "</a>";
}
this.template = this.template.replace(/{order}/, order);
this.box.innerHTML = this.template;
for(var j = 0, len = $(this.order).getElementsByTagName("a").length; j < len; j++)
{
addListener($(this.order).getElementsByTagName("a")[j], "click", clickFunc);
}
$(this.order).getElementsByTagName("a")[this.index].style.background = "#FF840C";
function clickFunc()
{
if(_this.timer)
clearInterval(_this.timer);
var n = (this.innerHTML.replace(/^s+|s+$/g,"")|0)-1;
_this.change(n);
var o = _this;
o.index = n;
o.timer = setInterval(function(){o.autoStart();}, o.timeout);
}
this.oA = document.createElement("a");
this.oA.href = "javascript: void(0)";
if(this.imgInfo[this.index].link)
{
this.oA.href = this.imgInfo[this.index].link
this.oA.target = "_blank";
}
$(this.innerbox).appendChild(this.oA);
this.oImg = new Image();
单位主页一个图片轮显的代码,两张图片!在点击1或者2的时候IE就自动新建窗口,并在IE地址栏中显示“javascript: void(0)”这个!!但是用360浏览器在极速模式下就没有这种情况!我在百度里查了一下,没找到相关的解决办法,求各位大神指点一下!谢谢了!!代码如下:
<script type="text/javascript">
<!--
var o = new Rotate(193, 93, "zgsw");
o.addImg([{url:"images/zgsw.png", link: "http://192.168.10.6/home/zgsw/"},{url:"images/zjlxx1.jpg", link: "http://192.168.10.6/home/xxwhjd/"}]);
o.show();
function Rotate(width, height, zgsw, timeout)
{
var isIE = navigator.appName == "Microsoft Internet Exploer";
var isFF = /Firefox/i.test(navigator.userAgent);
this.imgInfo = [];
this.width = parseInt(width);
this.height = parseInt(height);
this.box = $(zgsw);
this.timeout = timeout || 30000;
this.index = 0;
this.oImg = null;
this.timer = null;
this.innerbox = "asfman_" + uniqueID(6);
this.order = "asfman_" + uniqueID(6);
this.img = "asfman_" + uniqueID(6);
this.template = "<div id='" + this.innerbox + "'>\r\n" + "<div id='" + this.order + "'>\r\n{order}\r\n<div style='clear: both'></div>\r\n</div>";
//add css
var styleCss = "#" + this.innerbox + "{overflow: hidden; position: relative; width: " + this.width + "px; height: " + this.height + "px;}\r\n" +
"#" + this.order + "{position: absolute; right: 5px; bottom: 5px;}\r\n" +
"#" + this.order + " a{width: 16px; line-height: 16px; height: 16px; text-align: center; margin: 3px 3px 0 3px; border: 1px solid #c2c; float: left;}\r\n" + "#" + this.order + " a:link, #" + this.order + " a:visited{color:#000; text-decoration: none; background: #fff;}\r\n"+
"#" + this.order + " a:hover{background: #FF840C; text-decoration:none; }\r\n" +
"#" + this.innerbox + " img{border: 0; width: " + this.width + "px; height: " + this.height + "px;}\r\n";
function uniqueID(n)
{
var str="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
for(var ret = "", i = 0; i < n; i++)
{
ret += str.charAt(Math.floor(Math.random()*62));
}
return ret;
};
void function(cssText, doc)
{
doc = doc || document;
var oStyle = doc.createElement("style");
oStyle.type = "text/css";
if(oStyle.styleSheet)
{
oStyle.styleSheet.cssText = cssText;
}
else
{
oStyle.appendChild(doc.createTextNode(cssText));
}
doc.getElementsByTagName("head")[0].appendChild(oStyle);
}(styleCss);
function $(str){return document.getElementById(str);};
function addListener(o, type, fn)
{
var func = function()
{
return function(){fn.call(o);}
}();
if(isIE)
{
o.attachEvent("on" + type, func);
}
else if(isFF)
{
o.addEventListener(type, func, false);
}else{
o["on" + type] = func;
}
return func;
}
if(Rotate.initialize == undefined)
{
Rotate.prototype.addImg = function(obj)
{//{url: imgUrl, link: linkUrl, alt: alt, txt: txt}
if(obj)
{
if(obj.constructor == Array)
{
for(var i = 0, l = obj.length; i < l; i++)
{
this.imgInfo.push(obj);
}
}else
this.imgInfo.push(obj);
}
}
Rotate.prototype.show = function()
{
var _this = this;
var order = "";
for(var i = 1, l = this.imgInfo.length; i <= l; i++)
{
order += "<a href='javascript: void(0)'>" + i + "</a>";
}
this.template = this.template.replace(/{order}/, order);
this.box.innerHTML = this.template;
for(var j = 0, len = $(this.order).getElementsByTagName("a").length; j < len; j++)
{
addListener($(this.order).getElementsByTagName("a")[j], "click", clickFunc);
}
$(this.order).getElementsByTagName("a")[this.index].style.background = "#FF840C";
function clickFunc()
{
if(_this.timer)
clearInterval(_this.timer);
var n = (this.innerHTML.replace(/^s+|s+$/g,"")|0)-1;
_this.change(n);
var o = _this;
o.index = n;
o.timer = setInterval(function(){o.autoStart();}, o.timeout);
}
this.oA = document.createElement("a");
this.oA.href = "javascript: void(0)";
if(this.imgInfo[this.index].link)
{
this.oA.href = this.imgInfo[this.index].link
this.oA.target = "_blank";
}
$(this.innerbox).appendChild(this.oA);
this.oImg = new Image();