我将以下脚本添加到我的页面中,该页面用html和css编写,为我的图像创建一个模式框,只是为了让你在打开每个图像时看起来更专业,让你滚动浏览它们而不打开/多次关闭窗户。
<script language=javaScript>
<!-- Beginning of JavaScript -
var x,y,a,b,timer,thisbox,isbox,urlimg
var posleftvorher
var box
if (document.layers) {
var left_pos=".left=";
var top_pos=".top=";
var doc="document.";
var stl="";
}
if (document.all) {
var left_pos=".pixelLeft=";
var top_pos=".pixelTop=";
var doc="";
var stl=".style";
}
function openbox(thisbox) {
isbox = thisbox
if(document.layers) {
box = document.popupbox
box.visibility="visible"
document.popupbox.document.write("<img src='"+thisbox+"'>")
document.popupbox.document.close()
document.popupbox.left=x+25
document.popupbox.top=y
}
if(document.all) {
box = document.all.popupbox.style
box.visibility="visible"
popupbox.innerHTML="<img src='"+thisbox+"'>"
eval(doc+"popupbox"+stl+left_pos+(x+25))
eval(doc+"popupbox"+stl+top_pos+y)
timer=setTimeout("openbox(isbox)",50)
}
}
function closebox(){
clearTimeout(timer)
box.visibility="HIDDEN"
}
function handlerMM(e){
x = (document.layers) ? e.pageX : event.clientX
y = (document.layers) ? e.pageY : event.clientY
}
if
(document.layers){
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;
// - End of JavaScript - -->
</script>
然后我添加了一些css和html
<div id="main" class="mainstyle">
<a href="#" onMouseOver="openbox('sandra288.gif')" onMouseOut="closebox()"></a>
<a href="#" onMouseOver="openbox('catherine288.gif')" onMouseOut="closebox()"> </a>
<a href="#" onMouseOver="openbox('garbo288.gif')" onMouseOut="closebox()"></a>
<a href="#" onMouseOver="openbox('sandra288.gif')" onMouseOut="closebox()"></a>
<a href="#" onMouseOver="openbox('catherine288.gif')" onMouseOut="closebox()"></a>
<a href="#" onMouseOver="openbox('garbo288.gif')" onMouseOut="closebox()"></a>
<a href="#" onMouseOver="openbox('sandra288.gif')" onMouseOut="closebox()"></a>
<a href="#" onMouseOver="openbox('catherine288.gif')" onMouseOut="closebox()"> </a>
<a href="#" onMouseOver="openbox('garbo288.gif')" onMouseOut="closebox()"> </a>
<a href="#" onMouseOver="openbox('sandra288.gif')" onMouseOut="closebox()"> </a>
<a href="#" onMouseOver="openbox('catherine288.gif')" onMouseOut="closebox()"></a>
<a href="#" onMouseOver="openbox('garbo288.gif')" onMouseOut="closebox()"> </a>
</div>
<div id="popupbox" style="position:absolute"></div>
.mainstyle {
position: absolute;
font-family:Verdana;
color:DDDDDD;
font-size:40px;
}
A {
color:DDDDDD;
text-decoration:none;
}
现在当我实现这些代码和脚本没有任何反应时,图像甚至不会出现在页面中。
答案 0 :(得分:0)
它在ie工作。但不是铬,歌剧和火狐
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language=javaScript>
var x,y,a,b,timer,thisbox,isbox,urlimg;
var posleftvorher;
var box;
if (document.layers) {
var left_pos=".left=";
var top_pos=".top=";
var doc="document.";
var stl="";
}
if (document.all) {
var left_pos=".pixelLeft=";
var top_pos=".pixelTop=";
var doc="";
var stl=".style";
}
function openbox(thisbox) {
isbox = thisbox;
if(document.layers) {
box = document.popupbox;
box.visibility="visible";
document.popupbox.write("<img src='"+thisbox+"'>");
document.popupbox.close();
document.popupbox.left=x+25;
document.popupbox.top=y;
}
if(document.all) {
box = document.all.popupbox.style;
box.visibility="visible";
popupbox.innerHTML="<img src='"+thisbox+"'>";
eval(doc+"popupbox"+stl+left_pos+(x+25));
eval(doc+"popupbox"+stl+top_pos+y);
timer=setTimeout("openbox(isbox)",50);
}
}
function closebox(){
clearTimeout(timer);
box.visibility="HIDDEN";
}
function handlerMM(e){
x = (document.layers) ? e.pageX : event.clientX;
y = (document.layers) ? e.pageY : event.clientY;
}
if
(document.layers){
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;
</script>
<style type="text/css">
.mainstyle {
position: relative;
font-family:Verdana;
color:#FF0000;
font-size:40px;
}
a {
color:#0033FF;
text-decoration:none;
}
</style>
</head>
<body>
<div id="main" class="mainstyle">
<a href="#" onMouseOver="openbox('card.jpg')" onMouseOut="closebox()">aaaaaaaaaa</a>
<a href="#" onMouseOver="openbox('card.jpg')" onMouseOut="closebox()"> bbbbb</a>
<a href="#" onMouseOver="openbox('card.jpg')" onMouseOut="closebox()">ccccccc</a>
<a href="#" onMouseOver="openbox('card.jpg')" onMouseOut="closebox()">dddddddd</a>
<a href="#" onMouseOver="openbox('card.jpg')" onMouseOut="closebox()">eeeeeeee</a>
<a href="#" onMouseOver="openbox('card.jpg')" onMouseOut="closebox()">ffffffff</a>
<a href="#" onMouseOver="openbox('card.jpg')" onMouseOut="closebox()">ggggggg</a>
<a href="#" onMouseOver="openbox('card.jpg')" onMouseOut="closebox()"> hhhhhhhh</a>
<a href="#" onMouseOver="openbox('card.jpg')" onMouseOut="closebox()">iiiiiii </a>
<a href="#" onMouseOver="openbox('card.jpg')" onMouseOut="closebox()">jjjjjj </a>
<a href="#" onMouseOver="openbox('card.jpg')" onMouseOut="closebox()">kkkkkkk</a>
<a href="#" onMouseOver="openbox('card.jpg')" onMouseOut="closebox()"> lllll</a>
</div>
<p> </p>
<div id="popupbox" style="position:absolute"></div>
</body>
</html>
错误是,