I'm trying to get ElementById
from a txt file and pass it into marquee class. Do I need a javascript function for this?
Also, I can't get the white-space: nowrap
to work. Here is what I have put together so far. The javascript function credit goes to Sid function readTextFile
function readTextFile(file){
var rawFile = new XMLHttpRequest();
rawFile.open("GET", file, false);
rawFile.onreadystatechange = function ()
{
if(rawFile.readyState === 4)
{
if(rawFile.status === 200 || rawFile.status == 0)
{
var allText = rawFile.responseText;
alert(allText);
}
}
}
rawFile.send(null);
}
@-webkit-keyframes scroll {
0% {
-webkit-transform: translate(0 ,0);
}
100%{
-webkit-transform: translate(-100%, 0);
}
}
.marquee {
display:block;
width:100%
white-space: nowrap;
overflow:hidden;
}
.marquee span {
display:inline-block;
padding-left:100%;
-webkit-animation:scroll 15s infinite linear;
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="main.CSS" type="text/CSS">
</head>
<body>
<h1 class="marquee"><span><a href= readTextFile("file:///:/Users/justair07/Documents/cssmarquee/Message.txt")"> Test </a>.</span></h1>
</body>
</html>
Any help is much appreciated. I'm brand new to html, javascript, and css but I'm excited to learn.
Thank you!