1

I've been having this issue alot today. Every time I use the HTML DOM for finding parts of the page it always returns an error saying "...is not a function."

Everything from printing to the page to even simply changing the page title just fails.

I've used JSLint, looked it up, etc. and still don't have a clue what this means.

What's even more strange is that I easily got it to work on a different page using the same methods. Here was an attempt to create a loading animation for the title bar:

var loadingstat;
loadingstat = false;
var pgtA;
pgtA = 0;
setInterval(pgtUpdater(), 80);
function pgtUpdater() {
    if (pgtA == 0 && loadingstat = true) {
        document.getElementsByTagName[0]("title").innerHTML = "-=-=-";
        ++pgtA;
    } else {
        if (pgtA == 1 && loadingstat = true) {
            document.getElementsByTagName[0]("title").innerHTML = "=-=-=";
            ++pgtA;
        } else {
            if (pgtA == 2 && loadingstat = true) {
                document.getElementsByTagName[0]("title").innerHTML = "-/ \-";
                ++pgtA;
            } else {
                if (pgtA == 3 && loadingstat = true) {
                    document.getElementsByTagName[0]("title").innerHTML = "</ \>";
                    ++pgtA;
                } else {
                    if (pgtA == 4 && loadingstat = true) {
                        document.getElementsByTagName[0]("title").innerHTML = "/   \ ";
                        ++pgtA;
                    } else {
                        if (pgtA == 5 && loadingstat = true) {
                            document.getElementsByTagName[0]("title").innerHTML = "\   /";
                            ++pgtA;
                        } else {
                            if (pgtA == 6 && loadingstat = true) {
                                document.getElementsByTagName[0]("title").innerHTML = "<\ />";
                                ++pgtA;
                            } else {
                                if (pgtA == 7 && loadingstat = true) {
                                    document.getElementsByTagName[0]("title").innerHTML = "-\ /-";
                                    ++pgtA;
                                } else {
                                    if (pgtA == 8 && loadingstat = true) {
                                        document.getElementsByTagName[0]("title").innerHTML = "=-=-=";
                                        ++pgtA;
                                        } else {
                                            if (pgtA == 9 && loadingstat = true) {
                                                    document.getElementsByTagName[0]("title").innerHTML = "-=-=-";
                                                ++pgtA;
                                            } else {
                                                if (pgtA == 10 && loadingstat = true || loadingstat = false) {
                                                        document.getElementsByTagName[0]("title").innerHTML = "-----";
                                                    pgtA = 0;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

I've never actually had this issue until today. This always seems to happen whenever I try to edit an element in the page.

Also I am aware that these conditions aren't written properly, I'm currently working on fixing that.

3
  • 1
    To start change loadingstat = true to loadingstat == true. Commented Feb 20, 2018 at 23:00
  • 1
    Then change document.getElementsByTagName[0]("title") to document.getElementsByTagName("title")[0]. Commented Feb 20, 2018 at 23:01
  • @user7393973 Alright, I'll see what that does. Commented Feb 20, 2018 at 23:02

2 Answers 2

2

Here's a modified version of your code that you can try at about:blank (run the code from the console):

var title = document.getElementsByTagName('title')[0];
if ( !title ) {
  title = document.createElement('title');
  document.head.appendChild(title);
}
var frames = ['-=-=-', '=-=-=', '-/&nbsp;\\-', '</&nbsp;\\>', '/&nbsp;&nbsp;&nbsp;\\', '\\&nbsp;&nbsp;&nbsp;/', '<\\&nbsp;/>', '-\\&nbsp;/-', '=-=-=', '-=-=-', '-----'];
var i = 0;
setInterval(function() {
  title.innerHTML = frames[i];
  if ( i++ == 10 ) i = 0;
}, 500);
Sign up to request clarification or add additional context in comments.

1 Comment

Works perfect! The conditions used are missing a comparison, something like "loadingstat == true" which is an easy fix, I'll take care of the rest.
1

You are invoking pgtUpdater() in setInterval. Try just passing the function name. I tried an example function in the console, and as u can see the function is only invoked once when parantheses are used, this could be the issue.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.