How to execute a javascript code from the url of the site [closed]

1

Hello, is everything good? I was wondering if anyone can help me with something on my series site.

It does not have pages, or posts, that is: everything is done from the homepage.

To open a series, I use the code:

Abrir_Serie('exemplocode');

And what I wanted to do is like this:

link ('examplecode');

and automatically the code after the url would be executed ...

But I do not know how to do this

    
asked by anonymous 30.04.2016 / 22:25

1 answer

3

Well, you can use hashs in your url, which would be given after the url #.

If your url is for example link , you can get the test value to use in your function following form:

if(location.hash.search("serie") > -1){
    var serie = location.hash.split("#serie/")[1];
    Abrir_Serie(serie); //valor da variavel serie vai ser igual a teste
}

That way your site would not be vulnerable to malicious script injection.

    
30.04.2016 / 22:59