I'm guessing the reason it hasn't worked is because you're not waiting for DOM to initialize and the Web Browser has finished parsing the HTML.
The simplest 'fix' for this problem would be to hook into the window.onload
callback in your main.js
file:
// Wait for the DOM to finish loading.
var previousOnload = window.onload;
window.onload = function () {
// Execute any other `onload` function which may have been bound previously.
if (typeof previousOnload === 'function') {
previousOnload();
}
document.getElementById("url").value = "http://example.com";
});
However, it is preferred to listen for the DOM Ready event instead; if you're using jQuery then you can simply write:
// Wait for the DOM to initialize first.
$(function () {
document.getElementById("url").value = "http://example.com";
});
If you don't want to depend on jQuery then you could have a look into the super-lightweight DOMReady.js