你好我正在创建一个flash画廊网站,当我把它放在我的html中的let var = match
标签内时我的javascript工作但是当我尝试将它移动到外部.js文件时它停止工作。
HTML
<script></script>
CSS
<!doctype html>
<html lang="en" onLoad="flashy()">
<head>
<meta charset="utf-8">
<title>Flash Test</title>
<meta name="description" content="Flash stuff">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="styles/style.css">
<script src="js/scripts.js"></script>
</head>
<body>
<div id="siteText">
<h1>Anon Curb</h1>
</div>
<div id="flashmovie">
<object type="application/x-shockwave-flash" data="swfs/2cats.swf">'+
<param name="movie" value="swfs/2cats.swf">
</object>
</div>
<!-- end #container -->
<div id="buttoncon">
<button id="rand">Random</button>
<div id="buttons">
<button id="next">next</button>
<button id="back">Back</button>
<div id="title">2cats</div>
</div>
</div>
<!-- end #wrapper -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"></script>
</body>
</html>
JAVASCRIPT
body {
background-color: black;
margin: 0;
font-family: verdana, arial, hevetica, sans-serif;
}
#siteText {
font-size: 24px;
text-align: center;
color: white;
width: 100%;
margin-top: -10px;
}
#flashmovie {
width: 100%;
height: 80%;
margin-top: -1%;
float: center;
position: absolute;
margin-left: auto;
margin-right: auto;
}
#flashmovie object {
width: 100%;
height: 100%;
background-color: black;
}
button {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
width: 80px;
height: 30px;
}
#buttons {
width: 50%;
height: 50px;
position: relative;
left: 25%;
text-align: center;
background-color: black;
}
#buttoncon {
top: 90%;
width: 100%;
background-color: black;
position: absolute;
}
#back,
#next {
float: left;
cursor: pointer;
border: none;
}
#next {
float: right;
}
#title {
width: 60%;
margin: auto;
font-size: 22px;
color: #600;
text-align: center;
color: white;
}
#rand {
color: black;
position: relative;
left: 48%;
background-color: white;
border: none;
cursor: pointer;
z-index: 1;
margin-bottom: .5%;
margin-top: .5%;
}
因此,为了回顾一下代码的工作原理,我认为我刚刚搞砸了JQuery $(文件).ready之类的触发方式,或者我不应该用它开始?我是javascript的新手,所以你提出的任何建议都会有所帮助