Use external inline script as local function

Posted by Aidan on Stack Overflow See other posts from Stack Overflow or by Aidan
Published on 2014-06-06T02:47:48Z Indexed on 2014/06/06 3:24 UTC
Read the original article Hit count: 98

Had this closed once as a duplicate, yet the so-called duplicate DID NOT actually address my whole question.

I have found this script that, when run inline, returns your IP.

<script type="text/javascript" src="http://l2.io/ip.js"></script>

http://l2.io/ip.js Has nothing more than a line of code that says

document.write('123.123.123.123');

(But obviously with the user's IP address)

I want to use this IP address as a return string for a function DEFINED EXTERNALLY, BUT STILL ON MY DOMAIN. That is, I have a "scripts.js" that contains all the scripts I wish to use, and I would like to include it in that list as a local function that calls to the 12.io function, but javascript won't allow the <> tags, so I am unsure as to how to do this.

I.e.

function getIP() {
    return (THAT SCRIPT'S OUTPUT);
}

This is the topic this was supposedly a duplicate of, and it is very similar.

Get ip address with javascript

However, this DOES NOT address defining as a forwarded script it in my own script file.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about return-value