Pregunta

I am really sorry if the question already exists, but I have been searching everywhere for 30 minutes with no result. So I am wondering if I can see the actual javascript code, which is linked in the script tag, so I can learn from it. For example, I am really curious to take a look at this javascript code:

<script src="https://smart-ip.net/geoip-json?callback=ip_callback"></script>
¿Fue útil?

Solución

Yes, you can. Just copy its url and paste it in your browser's address bar.

Otros consejos

They are using HTML5 Geolocation or a server side alternative. You can learn more about that here for Javascript. More likely however, they are using PHP or another server side language, so you wouldn't be able to see the code for that. However, you can use the GeoIP API for PHP

viewing source in your browser

You can view the actual source inside your browser using this url:

view-source:[path_to_file]

So in your case this will be

view-source:https://smart-ip.net/geoip-json?callback=ip_callback

This works in Firefox and Chrome. Of course, you can also just download the file (paste the path in your browsers addressbar) and check it out in a texteditor like Notepad.

minified code

Probably the souce looks minified(no returns,tabs etc). You can use http://jsbeautifier.org to see more pretty indented code.

developer tools/http debugging

If seeing this url requires sessions or something, you can also run the html-page, and use chrome developer tools or firebug to see the network sources. You'll find the source passing by in the list.

Yes. Go to it. Your browser is called a "user agent" for a reason. Anything it can do, you can do, roughly.

The script will likely be minified, so the Javascript will be very unreadable. In some cases (like if you're looking at an open-source website) you can find the original source. That's the limitation on this approach.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top