were do i put that ? in the script type="text/javascript" tag ? or in
someware eles!

On 4 Apr, 16:16, Klaus Hartl <[EMAIL PROTECTED]> wrote:
> Klaus Hartl schrieb:
>
>
>
>
>
> > 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.
>
> If it's a global function the following could also work (again untested):
>
> window[functionNameFromHash]();
>
> -- Klaus

Reply via email to