Thursday, 26 September 2013

My old rubbish code is laughable

Most of yesterday I was adding a warning message to my old website to point out that the website was archived, with a link to the same page on the current website. Today I carried on with this task, and came across a file in the website directory named "Java.js".

I wondered what this could be, a javascript file that is named Java? Opening it up, it contained the following:

<script type="text/javascript" language="javascript">
if (top == self) location.replace("");

Wha???? What are those HTML script tags doing in a javascript file?

Then I checked to see if this file was actually linked to anywhere in the website. I found two pages that mentioned Java.js in their source. When I opened them, they contained the following line:

<link rel="javascript" href="../Java.js">

Eh? I didn't think you could include a javascript file by a link statement, that's just for including CSS isn't it? Well, I checked, and my assumption is correct. So I had a file named Java that is actually a javascript file. The javascript file that wouldn't do anything as it contained HTML. And the link to the javascript file wouldn't work anyway as you don't include javascript using a link tag.

I wrote the site myself, so I only have myself to blame. I find it quite funny just how wrong I got it though.

Most of the rest of the day I was doing some wordpress work.

No comments: