Pergunta

can a javascript document know the url from where is being loaded (not the referer) without url rewriting.

I load http://qqsd.foo/blabla.js loaded on my html page and I want my blabla.js script know this url and the parameters it could have passed.

Foi útil?

Solução

You could try this

<script src="http://qqsd.foo/blabla.js" id="blabla"></script>

then in your blabla.js file

alert(document.getElementById("blabla").getAttribute("src"))
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top