Tuesday, October 11th, 2005


Safari spits the dummy when it comes across a text-size:0em; clause in a CSS file. Which is kind of annoying, as it was nice to have zero-sized text, which naturally doesn’t appear, and replace it with an image, which does appear.

Saves having to do a node.style.display = "block"; Oh well.

View Comments (0)   RSS Feed for Comments on this Post

Most programming languages have some sort of an include/import feature: this allows you to have code in one file and reference it from another. JavaScript doesn’t.

Most people would say: “Well, just put another <script src=''> in the HTML document”. Well, that’s all well and good, but if I’m creating a framework for others to use, and I want them to have to do as little work as possible, and I’m likely to update the framework in the future, possibly including new features that reference new files, I don’t want to have to get them to do this. Especially if the script is located on my server, and they just reference it.

This had kept me to working with one monolithic file: at the moment I have around 36,812 characters in that file, and it’s getting unmanageable. Just to keep SubEthaEdit’s function menu clean, I’ve been assigning anonymous functions to variables:

var funcname = function () {return "Spaghetti";}

But then, I came across this function:

function include(src){
    if (typeof include[src] == "undefined") {
        include[src] = true;
        document.write("\n<script type=\"text/javascript\" src=\"" + src + "\"></script>");
    }
}

You can then just use an include(URI); call to have the other script executed.

It’s kind of a hack, but it works, and I like it. Browser independant, too.

View Comments (0)   RSS Feed for Comments on this Post

Apparently, Safari does not ‘render’ comments in HTML.

That sounds silly, but it strips them out. Which means that JavaScripts that use comments as placeholders will fail. Which means I can do one of two things: not support Safari, or rewrite my handlers so they use p, div or span tags, instead of comments.

This really annoys me, as it’s much nicer to be able to tell someone to put: <!--catchpa--> into their web page, rather than <p id="catchpa"></p>

What other self-closing tags could I use? <br id="catchpa" /> ???

It’s going to mean a significant restructure of my code. But since I’ve learned how to import scripts, that might not be such a bad idea.

View Comments (0)   RSS Feed for Comments on this Post