Here's what I have so far...
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="main.css"/>
<title>Tommay's Super Secret Database</title>
</head>
<body>
<p id="q">Establishing connection</p>
<p id="w">Checking the time</p>
<p id="e">Doing other stuff</p>
<p id="r">Locating cows</p>
<script type="text/javascript">
var q = document.getElementById("q");
var qdisplay = q.style.display;
window.onload = active();
function active() {
if (qdisplay == "block") {
window.alert("IT WORKS!!");
}
}
</script>
</body>
</html>
CSS:
body {
background: #c33f3f;
}
#q {
font-family: 'Courier New', Courier, 'Lucida Sans Typewriter', 'Lucida Typewriter', monospace;
margin-top: 300px;
color: white;
margin-left: 20px;
dsplay: block;
}
Basically, what I'm planning is to cycle through the q, w, e, and r paragraphs after a certain amount of time. I'll do this by using the active function to see which one's currently being displayed. Depending on which one's display is set to block, it'll run a separate function, which will go through three different .innerHTML things, each one adding another period at the end of the scentence. This will create a kind of animated ... thing.
This may not make any sense at all... For example, with Establishing connection, it would run through - Establishing connection - to - Establishing connection. - then - Establishing connection.. - and lastly - Establishing connection... - and then it would start at the beginning again. And it would do that a couple times, until it sets its display to "none," sets the display of w to "block," and then calls the active() function.
NOW, on to the actual problem. I ran this, and... nothing happened. the alert never popped up or anything. I originally thought it was because the active() function wasn't running, so I added the window.onload thing, but it still didn't work. WHICH leads me to believe I'm doing something wrong with detecting if the style of q is block. How does one go about doing that?
By the way, I know this doesn't ACTUALLY show the progress of loading. I'm just screwing around with JavaScript.
YES, I saw that other question, and it didn't work. Here's how I implemented it - I may have made a mistake?
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="main.css"/>
<title>Loading...</title>
</head>
<body>
<p id="q">Establishing connection...</p>
<script type="text/javascript">
var q = document.getElementById("q");
var qdisplay = window.getComputedStyle("display");
window.onload = active();
function active() {
if (qdisplay == "block") {
window.alert("IT WORKS!!");
}
}
</script>
</body>
</html>
I also tried using q.getComputedStyle, with the same results. Help?