I'm amazed at how many people don't use a very simple shortcut for document.getElementById. This is for all the people who don't use a javascript library like jQuery. All you have to do is include this code somewhere on your page Code: function $(element) { return document.getElementById(element); } Then when you want to use document.getElementById('id'); just type $('id'); instead. Example Code: <html> ...
function $(element) { return document.getElementById(element); }
document.getElementById('id');
<html>
I was having troubles the other day loading a YouTube-video (using Firefox). The URL: http://www.youtube.com/v/W13GifsFFfk?version=3 (this url may work on your machine, but it doesn't on mine (when I use Firefox)). My guess was that the problem was caused by the video's HD-quality. So I googled around to see how we can force YouTube to play videos in a specific quality. I found that we can do it by appending the following to the YouTube-url: &vq=small ...
I was working the other day on a script for setting the height of an iframe to match the height of its content and noticed that under certain circumstances the iframe gets its scroll bars 'back' when it shouldn't. This happens mainly when the iframe is given a very small width. Overflow: hidden solves the problem in Firefox (most of the time), but not in IE. This browsers needs scrolling="no", which also works in non-IE. However, attributes like scrolling="no" and frameborder="no" ...
Updated 01-12-2012 at 10:36 AM by molendijk (Corrections in text)
In non-IE except Google Chrome, we can call functions from inside a select box by putting things like the following in the options: <option value="bla" onclick="some_function()"></option> <option value="bla" onclick="window.open('http://www.google.com')"></option> etc. This is not possible in IE and Google Chrome. In an earlier attempt to solve the problem, I created a script based on the idea that ...
Updated 12-01-2011 at 09:46 AM by molendijk (Corrections in text)
While surfing on the Internet I found this page on how to pass data from one page to another. After a while, I realized that the script used on the page actually contains a technique (implicitly) for deferring document.write. Just for the fun of it, I modified the script so as to have some easy ways of dynamically inserting internal and external content into a given div via document.write. Here it is: Code: <script type="text/javascript"> function HttpRequest(url){ var pageRequest ...
<script type="text/javascript"> function HttpRequest(url){ var pageRequest
Updated 10-31-2011 at 06:05 PM by molendijk (Correction)