IE 8每次运行我的网站时都会阻止我的自定义脚本,我需要点击“允许脚本”才能正确运行它。它很无聊。
有什么想法吗?
剧本:
// JavaScript Document
var char=0;
var caption = "";
var standby;
var msg = "Lorem ipsum dolor sit amet, consenctuinv isdrulix core";
var selectedItem = 1;
var lastItem;
var fotos = new Array();
fotos[0] = "Img/Dela/wan_crowd2.jpg"
fotos[1] = "Img/Dela/wan_dog.jpg";
fotos[2] = "Img/Dela/wan_spirit.jpg"
fotos[3] = "Img/Dela/wan_pose_bra.jpg";
fotos[4] = "Img/Dela/wan_crowd2.jpg"
var interval;
$(function(){
//Main rotator ----------------------------------------------------------------------------------------
if($("#mainPhoto").html() == ""){
$("#mainPhoto").html($("<img></img>").attr({src:fotos[1]}));
$(".control:first").css({color:"#fff",background:"none"});
selectedItem = 2;
lastItem = 1;
ShowCaption(null);
}
interval = setInterval("AutoRotate()",5000);
$(".control,#mainPhoto").hover(function(){
clearInterval(interval);
},function(){
interval = setInterval("AutoRotate()",5000);
});
$(".control").click(function(){
var idFoto = $(this).text();
$("#runnerDiv").css("background","url(" + fotos[(selectedItem - 1)] + ") no-repeat top left");
$("#mainPhoto").html($("<img></img>").attr({src:fotos[parseInt(idFoto)]}).css({width:"407px",height:"289px",display:"none"}).fadeIn(1500));
$(this).parent().nextAll().find("a").css({color:"#e4065d",backgroundColor:"#fff"});
$(this).parent().prevAll().find("a").css({color:"#e4065d",backgroundColor:"#fff"});
$(this).css({color:"#fff",background:"none"});
lastItem = idFoto;
if((parseInt(idFoto) + 1) <= 4)
selectedItem = (parseInt(idFoto) + 1);
else
selectedItem = 1;
ShowCaption(null);
});
//end main rotator --------------------------------------------------------------------------------
$("#perfilWrapper ul li").hover(function(){
$(this).css("z-index","10");
$(this).find("img").css("background","#c9c").stop().animate({
width:"113px",
height:"85px",
left:'-20px',
top:'-50px'
},200);
},function(){
$(this).css("z-index","0");
$(this).find("img").css("background","#f0f0f0").stop().animate({
width:"54px",
height:"40px", left:'0',
top:'0'
},500);
});
});
function AutoRotate(){
var controles = $(".control");
$("#runnerDiv").css("background","url(" + fotos[(selectedItem - 1)] + ") no-repeat top left");
$("#mainPhoto").html($("<img></img>").attr({src:fotos[selectedItem]}).css({display:"none"}).fadeIn(1500));
var colorName = "";
var numColor = parseInt(lastItem);
switch(numColor)
{
case 1:
colorName = "#0c3";
break;
case 2:
colorName = "#3AABE7";
break;
case 3:
colorName = "#EAC900";
break;
case 4:
colorName = "#A203FD";
break;
}
controles.filter(function(){return $(this).text() == selectedItem.toString();}).css({color:"#fff",background:"none"});
$("#mainPhoto").attr("href","home.aspx?id=" + selectedItem);//link das imagens
if(lastItem != null)
{
controles.filter(function(){return $(this).text() == lastItem.toString();}).css({color:colorName,background:"#fff"});
}
lastItem = selectedItem;
if(selectedItem <= 3){
selectedItem++;
}
else
selectedItem = 1;
ShowCaption(null);
}
function ShowCaption(obj){
caption = msg;
if(caption){
type();
}
}
function type(){
$("#textControl").html(caption.substring(0,char++));
if(char < caption.length + 1){
setTimeout("type()",10);
}
else
{
char = 0;
caption ="";
}
}
答案 0 :(得分:2)
如果它通过文件系统直接在本地服务(而不是通过本地Web服务器),IE8将阻止许多脚本被执行,因为恶意脚本可以通过这种方式造成更多的破坏。