I have built this small HTML file you can see here https://alterego.cc/mypublicip/ that returns your public IP. If you inspect the code of the page you can actually see the HTML in there, because that’s an HTML file of course
What I would actually like to achieve is something like this https://wtfismyip.com/text (from someone else) where if you inspect the code you can see it’s just a text file there. No additional tags or anything in particular
How could I achieve the same result?
I have tried a bit of everything but I always end up having some HTML code in there. In particular with DIV and innerText but no particular luck so far. I believe I am following the wrong approach and there is something I am missing
Thanks!
2
Answers
I create 2 files. firstPage.php and secondPage.php
Try this code.
firstPage.php
secondPage.php
What you need is to set the content type of the response to plain text instead of html:
Place this in the first line of your php code of the will do.
However, you won’t be able to set head tags in HTML, which means you will have to remove the title and script tag, etc. as they will be displayed as plain text and won’t be rendered.
EDIT: Your content is displayed by grabbing data through ajax, but you can simply just use one file of php and echo the ip out.