js数组与文本中的问题,JS实现图片翻书效果示例代码

图片 1

js 图片翻书效果。 

picture.html

呼救!比方笔者今后有意气风发部分json数据,{“doc_id”:”25″,”doc_name”:”活动风韵”,”doc_type”:”picture”,”doc_local”:”E:ip7p2016_1220161209_IMG_0729.JPG”,”property”:”1,5,24″},{“doc_id”:”26″,”doc_name”:”活动风韵”,”doc_type”:”picture”,”doc_local”:”E:ip7p2016_1220161209_IMG_0730.JPG”,”property”:”1,5,25″},{“doc_id”:”27″,”doc_name”:”活动风韵”,”doc_type”:”picture”,”doc_local”:”E:ip7p2016_1220161209_IMG_0731.JPG”,”property”:”1,5,25″},之后有多少个数组[1,5,25]当数码property中数字均能够在数组中找到的时候将这一条数据插手到一个新的数组中。求问这种js应该怎么写

picture.html 

复制代码 代码如下:

<html
xmlns=”; 

<html xmlns=”;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″
/>
<title>JS实现图片翻书效果</title>
<META http-equiv=imagetoolbar content=no>
<link rel=”stylesheet” type=”text/css” href=”picture.css”/>
<script type=”text/javascript” src=”picture.js”></script>
<BODY>

<head> 

<DIV id=center>
<!–图片地点–>
<DIV id=DHTMLBOOK>
<SPAN class=page onMouseDown=”return false;” ondblclick=TPL();
onclick=TPL();><IMG class=img></SPAN>
<SPAN class=”page right” onmousedown=”return false;”
ondblclick=TPR(); onclick=TPR();><IMG class=img style=”LEFT:
-100%”></SPAN>
<SPAN class=”page turn” onMouseDown=”return false;” ondblclick=TPL();
onclick=TPL();><IMG class=img style=”FILTER: alpha(); opacity:
1″></SPAN>
<SPAN class=”page turn right” onmousedown=”return false;”
ondblclick=TPR(); onclick=TPR();><IMG class=img style=”FILTER:
alpha(); LEFT: -100%; opacity: 1″></SPAN>
<!–文字地点–>
<DIV id=TXTBOX></DIV>
</DIV>
</DIV>

<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″
/> 

<DIV id=imgsrc style=”VISIBILITY: hidden”>
<IMG alt=”In the early morning he departed.”
src=”babi/86d6277f9e2f0708ce332da4e924b899a901f264.jpg”>
<IMG alt=”Believing she had dreamed of the roar of his bike,”
src=”babi/c4aaee1ejw1e3jb8r868vj.jpg”>
<IMG alt=”she woke up to the sunshine in her eyelids.”
src=”babi/7-121205155537-52.jpg”>
<IMG alt=”she woke up to the sunshine in her eyelids.”
src=”babi/c4aaee1ejw1e3jb91py0fj.jpg”>
<IMG alt=”she woke up to the sunshine in her eyelids.”
src=”babi/c4aaee1ejw1e3jb94nx7bj.jpg”>
</DIV>
</BODY></HTML>

<title>JS实现图片翻书效果–www.jbxue.com</title> 

picture.css

<META http-equiv=imagetoolbar content=no> 

复制代码 代码如下:

<link rel=”stylesheet” type=”text/css” href=”picture.css”/> 

#center {
LEFT: 50%; POSITION: absolute; TOP: 50%
}
#DHTMLBOOK {
BACKGROUND: #000; LEFT: -210px; VISIBILITY: hidden; WIDTH: 210px;
POSITION: relative; TOP: -160px; HEIGHT: 160px
}
#TXTBOX {
FONT-SIZE: 0.8em; WIDTH: 210px; COLOR: #aba193; FONT-FAMILY: verdana;
POSITION: absolute; TOP: 160px; TEXT-ALIGN: center
}
.page {
OVERFLOW: hidden; BORDER-LEFT: #000000 1px solid; WIDTH: 50%; CURSOR:
pointer; POSITION: absolute; HEIGHT: 100%
}
.right {
BORDER-RIGHT: #000000 1px solid; LEFT: 50%
}
.turn {
BACKGROUND: #000000
}
.img {
WIDTH: 200%; POSITION: absolute; HEIGHT: 100%
}

<script type=”text/javascript” src=”picture.js”></script> 

picture.js

<BODY> 

复制代码 代码如下:

<DIV id=center> 

document.onselectstart = function () { return false; }

<!–图片地点–> 

var nI = 0;
var kI = 0;
var run = false;

<DIV id=DHTMLBOOK> 

function setOpacity(obj,o) {
if (o<0) o=0; else if (o>100) o = 100;
if (obj.filters)obj.filters.alpha.opacity=o; else obj.style.opacity =
o/100;
}
function TPR__(p) {
P1.style.left = 50-(2.5*p)+”%”;
P1.style.width = (2.5*p)+”%”;
setOpacity(P1i, .5*p*p);
if (p == 20) run = false;
}
function TPR_(p) {
P2.style.width = 50-(2.5*p)+”%”;
setOpacity(P2i, 100-.5*(p*p));
if (p == 20) {
P2i.src = IMGSRC[kI].src;
setOpacity(P2i, 100);
P2.style.width = “50%”;
for(var i=1; i<=20; i++) setTimeout(“TPR__(“+i+”)”, i*32);
}
}
function TPR() {
if (!run) {
run = true;
P01i.src = IMGSRC[kI].src;
P1.style.width = 0;
kI++;
if (kI>=nI) kI = 0;
titLe(kI);
P02i.src = IMGSRC[kI].src;
P1i.src = IMGSRC[kI].src;
for (var i=1; i<=20; i++) setTimeout(“TPR_(“+i+”)”, i*32);
} else setTimeout(“TPR()”, 100);
}

<SPAN class=page onMouseDown=”return false;” ondblclick=TPL();
onclick=TPL();><IMG class=img></SPAN> 

function TPL__(p) {
P2.style.width = (2.5*p)+”%”;
setOpacity(P2i, .5*p*p);
if (p == 20) run = false;
}
function TPL_(p) {
P1.style.left = (2.5*p)+”%”;
P1.style.width = 40+(10-2.5*p)+”%”;
setOpacity(P1i, 100-.5*(p*p));
if (p == 20) {
P1i.src = IMGSRC[kI].src;
setOpacity(P1i, 100);
P1.style.left = 0;
P1.style.width = “50%”;
for(var i=1; i<=20; i++) setTimeout(“TPL__(“+i+”)”, i*32);
}
}
function TPL() {
if (!run) {
run = true;
P02i.src = IMGSRC[kI].src;
P2.style.width = 0;
kI–;
if (kI < 0) kI = nI-1;
titLe(kI);
P01i.src = IMGSRC[kI].src;
P2i.src = IMGSRC[kI].src;
for(var i=1; i<=20; i++) setTimeout(“TPL_(“+i+”)”, i*32);
} else setTimeout(“TPL()”, 100);
}
function titLe(p) {
document.getElementById(“TXTBOX”).innerHTML = IMGSRC[p].alt;
}
onload = function() {
IMGSRC =
document.getElementById(“imgsrc”).getElementsByTagName(“img”);
DB = document.getElementById(“DHTMLBOOK”);
P01 = DB.getElementsByTagName(“span”)[0];
P01i = P01.getElementsByTagName(“img”)[0];
P02 = DB.getElementsByTagName(“span”)[1];
P02i = P02.getElementsByTagName(“img”)[0];
P1 = DB.getElementsByTagName(“span”)[2];
P1i = P1.getElementsByTagName(“img”)[0];
P2 = DB.getElementsByTagName(“span”)[3];
P2i = P2.getElementsByTagName(“img”)[0];
nI = IMGSRC.length;
P1i.src = IMGSRC[kI].src;
P2i.src = IMGSRC[kI].src;
titLe(kI);
DB.style.visibility = “visible”;
}

<SPAN class=”page right” onmousedown=”return false;”
ondblclick=TPR(); onclick=TPR();><IMG class=img style=”LEFT:
-100%”></SPAN> 

复制代码 代码如下: html
xmlns=”” head meta http-equiv=”Content-Type”
content=”text/html; charset=utf-8″ / titleJS落成图片翻书效…

<SPAN class=”page turn” onMouseDown=”return false;” ondblclick=TPL();
onclick=TPL();><IMG class=img style=”FILTER: alpha(); opacity:
1″></SPAN> 

<SPAN class=”page turn right” onmousedown=”return false;”
ondblclick=TPR(); onclick=TPR();><IMG class=img style=”FILTER:
alpha(); LEFT: -100%; opacity: 1″></SPAN> 

<!–文字地方–> 

<DIV id=TXTBOX></DIV> 

</DIV> 

</DIV> 

<DIV id=imgsrc style=”VISIBILITY: hidden”> 

<IMG alt=”In the early morning he departed.”
src=”babi/86d6277f9e2f0708ce332da4e924b899a901f264.jpg”> 

<IMG alt=”Believing she had dreamed of the roar of his bike,”
src=”babi/c4aaee1ejw1e3jb8r868vj.jpg”> 

<IMG alt=”she woke up to the sunshine in her eyelids.”
src=”babi/7-121205155537-52.jpg”> 

<IMG alt=”she woke up to the sunshine in her eyelids.”
src=”babi/c4aaee1ejw1e3jb91py0fj.jpg”> 

<IMG alt=”she woke up to the sunshine in her eyelids.”
src=”babi/c4aaee1ejw1e3jb94nx7bj.jpg”> 

</DIV> 

</BODY></HTML> 

picture.css 

#center { 

LEFT: 50%; POSITION: absolute; TOP: 50% 

#DHTMLBOOK { 

BACKGROUND: #000; LEFT: -210px; VISIBILITY: hidden; WIDTH: 210px;
POSITION: relative; TOP: -160px; HEIGHT: 160px 

#TXTBOX { 

FONT-SIZE: 0.8em; WIDTH: 210px; COLOR: #aba193; FONT-FAMILY: verdana;
POSITION: absolute; TOP: 160px; TEXT-ALIGN: center 

.page { 

OVERFLOW: hidden; BORDER-LEFT: #000000 1px solid; WIDTH: 50%; CURSOR:
pointer; POSITION: absolute; HEIGHT: 100% 

.right { 

BORDER-RIGHT: #000000 1px solid; LEFT: 50% 

.turn { 

BACKGROUND: #000000 

.img { 

WIDTH: 200%; POSITION: absolute; HEIGHT: 100% 

picture.js 

document.onselectstart = function () {
return false; } 

var nI = 0; 

var kI = 0; 

var run = false; 

function setOpacity(obj,o) { 

if (o<0) o=0; else if (o>100) o = 100; 

if (obj.filters)obj.filters.alpha.opacity=o; else obj.style.opacity =
o/100; 

function TPR__(p) { 

P1.style.left = 50-(2.5*p)+”%”; 

P1.style.width = (2.5*p)+”%”; 

setOpacity(P1i, .5*p*p); 

if (p == 20) run = false; 

function TPR_(p) { 

P2.style.width = 50-(2.5*p)+”%”; 

setOpacity(P2i, 100-.5*(p*p)); 

if (p == 20) { 

P2i.src = IMGSRC[kI].src; 

setOpacity(P2i, 100); 

P2.style.width = “50%”; 

for(var i=1; i<=20; i++) setTimeout(“TPR__(“+i+”)”, i*32); 

function TPR() { 

if (!run) { 

run = true; 

P01i.src = IMGSRC[kI].src; 

P1.style.width = 0; 

kI++; 

if (kI>=nI) kI = 0; 

titLe(kI); 

P02i.src = IMGSRC[kI].src; 

P1i.src = IMGSRC[kI].src; 

for (var i=1; i<=20; i++) setTimeout(“TPR_(“+i+”)”, i*32); 

} else setTimeout(“TPR()”, 100); 

function TPL__(p) { 

P2.style.width = (2.5*p)+”%”; 

setOpacity(P2i, .5*p*p); 

if (p == 20) run = false; 

function TPL_(p) { 

P1.style.left = (2.5*p)+”%”; 

P1.style.width = 40+(10-2.5*p)+”%”; 

setOpacity(P1i, 100-.5*(p*p)); 

if (p == 20) { 

P1i.src = IMGSRC[kI].src; 

setOpacity(P1i, 100); 

P1.style.left = 0; 

P1.style.width = “50%”; 

for(var i=1; i<=20; i++) setTimeout(“TPL__(“+i+”)”, i*32); 

function TPL() { 

if (!run) { 

run = true; 

P02i.src = IMGSRC[kI].src; 

P2.style.width = 0; 

kI–; 

if (kI < 0) kI = nI-1; 

titLe(kI); 

P01i.src = IMGSRC[kI].src; 

P2i.src = IMGSRC[kI].src; 

for(var i=1; i<=20; i++) setTimeout(“TPL_(“+i+”)”, i*32); 

} else setTimeout(“TPL()”, 100); 

function titLe(p) { 

document.getElementById(“TXTBOX”).innerHTML = IMGSRC[p].alt; 

onload = function() { 

IMGSRC = document.getElementById(“imgsrc”).getElementsByTagName(“img”); 

DB = document.getElementById(“DHTMLBOOK”); 

P01 = DB.getElementsByTagName(“span”)[0]; 

P01i = P01.getElementsByTagName(“img”)[0]; 

P02 = DB.getElementsByTagName(“span”)[1]; 

P02i = P02.getElementsByTagName(“img”)[0]; 

P1 = DB.getElementsByTagName(“span”)[2]; 

P1i = P1.getElementsByTagName(“img”)[0]; 

P2 = DB.getElementsByTagName(“span”)[3]; 

P2i = P2.getElementsByTagName(“img”)[0]; 

nI = IMGSRC.length; 

P1i.src = IMGSRC[kI].src; 

P2i.src = IMGSRC[kI].src; 

titLe(kI); 

DB.style.visibility = “visible”; 

发表评论

电子邮件地址不会被公开。 必填项已用*标注