Created
August 4, 2018 15:08
-
-
Save AlainODea/35a33b21ac6947990bebee4e2b980d79 to your computer and use it in GitHub Desktop.
CORS from file:// origin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>What is my IP?</title> | |
| <script type="text/javascript"> | |
| function reqListener () { | |
| var response = JSON.parse(this.responseText); | |
| document.getElementById("ip").innerText = | |
| 'Your public IP is ' + response.origin; | |
| } | |
| var oReq = new XMLHttpRequest(); | |
| oReq.addEventListener("load", reqListener); | |
| oReq.open("GET", "https://nghttp2.org/httpbin/ip"); | |
| oReq.send(); | |
| </script> | |
| </head> | |
| <body> | |
| <h1>What is my IP?</h1> | |
| <div id="ip">Calculating your public IP...</div> | |
| </body> | |
| </html> |
Author
Author
This does not work (without user clicking Allow Restricted Content) in Internet Explorer 11.551.16299.0.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This may cease to work in future.
This file successfully makes the CORS request when downloaded and run locally in: