Display IP address on secure site

Hi,

I have assigned SSL to a website that has a need to display the users’ IP address, but now the IP address is not displaying.

The site is https://eliminators.ca/verify_addy.php and the IP address should appear just below “This is your IP address”.

Can anyone tell me a way so this can still function?

TIA

Your current webpage has lots of errors about mixed content from non-SSL sources, which is probably why portions of it are failing to work.

My solution derived from this StackOverflow comment:

<div id="ip_result">Fetching IP address...</div>

<script>
	const resultDiv = document.getElementById("ip_result");
	function getIPAddress(json) {
	     resultDiv.innerHTML="My IP Address is: " + (json.ip);
	}
</script>

<script src="https://ipinfo.io/?format=jsonp&callback=getIPAddress"></script>

Tested and working in RapidWeaver 8 and over SSL. It is pure HTML + JavaScript. Place it wherever you want the IP address shown in the page.

‘ip_result’ is the container for displaying the IP address. We put some simple content (Fetching IP address…) in here while the page is loading.

The JavaScript uses the document object to get the container as a variable. Then we define a new function called getIPAddress and pass our JSON callback from https://ipinfo.io as an argument. Output a simple text string and the returned IP address within the function.

The text ‘My IP Address is:’ can be changed deleted if it is not required.

Emphasis on the fact that this is a very simple solution. Won’t work if JavaScript is disabled or perhaps if certain privacy blocks are in place. Can’t say for sure what will happen if a proxy is being used. But if you want simple, this should work as a copy and paste solution.

2 Likes

You have a lot of mixed content on the page listed above:

Not sure how you are getting the IP address, but I bet it’s being blocked because of the mixed (unsecure) content.

2 Likes

Very Helpful. I like helpful people who answer, is keeps us mortals from having to ask 1000’s of questions and making 1000’s of mistakes.

Super Thanks

1 Like

Many thanks @willwood. That works perfectly. I appreciate this.

Hi @teefers - I am not sure where that content comes from, I just used a bit of code I found online. I also just in the past couple of days added SSL to my sites, so I am finding a lot of instances of http instead of https, so I am working through that too. Thanks for the reply. :slight_smile:

Peg I also had my host redirect my sites to https today.
Then I went through every project in RW and switched the several site addresses, General and publish settings. Then I cleared the caches in safari and firefox, then I went through my safari history and cleared out all those http history items from my sites in the history.

Next try Develop>show source>console>warnings

see Teefers post above

Others on this forum have found the following website useful in trying to determine why a secure website is still pulling-in things from insecure sources or displaying other related errors:

https://www.whynopadlock.com/

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.