I have a problem with JavaScript running in Firefox. The following is an example script without problems in other browsers except Firefox.
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[i]] = hash[1];
}
if (vars[0] != ' ')
{
document.all['companyURL'].innerHTML = vars[0];
document.getElementById('domain').value = vars[0];
}
Thus, this code runs at page load time and should capture values after the URL and replace the line of text on the page with what is in the URL.
This is the line of text that needs to be replaced (yourcompany.com):
<h1><a href="" id="companyURL" name="companyURL">yourcompany.com</a> is available.<img src="images/checkmark_64.png" alt="check image"></h1>
So, if the URL is “google.com?hello.com”, then the text on the page should change from “yourcompany.com” to “hello.com”, but when the page loads in Firefox, it gives me the error “ document.all undefined "and points to a line of code with this in it.
document.all['companyURL'].innerHTML = vars[0];
, , - , . , !
!