Board Thread:General Coding Help/@comment-5501257-20160822144858/@comment-1757994-20160823095612

Let's tear your code apart, because I doubt it does what you think it does.

selects all  tags that are descendants of elements with class   and attaches the specified function as the click event hander to each of them. On the first page link, there are 6 of them (1, 2, 3, 4, 26, and Next). There can be more or less depending upon where you are and how many total there are.

If you click any of them, then the click handler runs, which sets an interval timer. The category page also has other click handlers on those buttons to handle pagination. At the very least, Wikia's click handler paginates the gallery to whatever page's button was clicked. It does other things, too, but we'll worry about that later.

Later, in the interval handler, which runs after all the click handlers have completed,  selects all   tags that are descendants of elements with class , which are several, some the same and some different from the 6 or so before, and tests if any of them has class. Well, one of them is always going to be active, so the  condition is always going to be true.

The  block clears that interval timer. Then  selects all   tags on the page and sets their   attribute to "_blank". For example, the  link at the bottom of the page. Click on it and watch it open a new window.

Notice that at no point did clicking on a button open a new window for the gallery, because their  attributes are undefined.

Now go back and consider Wikia's click handlers. They're doing two things rather obviously, other than pagination:
 * 1) They cancel the click event, stopping the default open behavior with the href attribute. You can tell because normally the page does not reload. The gallery merely scrolls. Even if the   attribute were predefined, clicking on those buttons wouldn't open a new window.
 * 2) They rebuild the button bar, discarding several old buttons and making new ones. Some of them stay the same, but even the ones that stay are rebuilt.

Your code has an additional problem called a race condition. You set the interval timer probably because you realized you wanted to assign  attributes after the button bar had been built, but that only works if the button bar is completed before the interval expires. If the interval expires first, then the button building process erases the attributes you just assigned on the buttons that remain, plus you never assigned the attributes on buttons that didn't exist a moment ago. The outcome depends on which process wins the "race," which is why it's called a race condition. A fast computer on a fast Internet connection probably completes building the new bar before the interval expires. On a slow computer on a slow Internet connection, the button bar probably finishes last. In between, it could go either way, maybe even varying depending on conditions that users can't observe, so sometimes it would work and sometimes it would fail to set the attributes.

Your stated goal of opening pages in new windows can probably be achieved, but it's going to require much different code. The first thing it has to do is disable Wikia's click handlers. It's probably possible, but I don't keep that kind of code in my head. Unless someone beats me to it, I'll have to write more on it later. Then you have to set up the buttons the way you want. That part shouldn't be too hard.