Rikard.C schrieb:
Hi. does anyone know how to call a function from a url like
http://www.XYZ.com/page.html#FUNCTION

???

Here's what you can try (untested):

try {
    var functionNameFromHash = location.hash.replace('#', '');
    eval(functionNameFromHash + '()');
} catch(e) {
    // fail silently
}

I can't think of another way than using eval here, one of the rare cases. And I recommend using try/catch here, who knows whats in the URL's hash which isn't allowed in a function name.


-- Klaus

Reply via email to