Help - Search - Members - Calendar
Full Version: Javascript For Secure Server "certificate"
MonsterSmallBusiness Forums > MonsterWebDesign > Designing Your Storefront
Tim_in_TN
I have to say, I really enjoyed developing a site at MonsterCommerce for my client, and I really appreciated the help I got from everyone here on the forum. With that in mind, I've decided to "give back to the community" and share a couple of pieces of javascript code and an image that would be ideal for all y'all.

What this code does is, determine if the page being viewed is coming from a secure server by way of checking the opening string of the page's URL. If it begins with https, it returns a "certificate" image, otherwise it remains blank. It's not a real certificate, but for those on the shared SSL, it would do just fine I guess. I have it linked at SoWhimsy.com to a popup that explains briefly how to tell you're on a secure server.

In fact, I'm going to give you the popup code as well, which I found at javascripts.com. This is a great popup code, because it centers the popup on your screen.

Here's how the code works. In the Top of Page Editor, place the following (this is the popup code):


<script language="javascript">

<!-- start script here

/******************************
Script done by Eric King
URL: http://redrival.com/eak/

you must keep these lines in
to use this script.
******************************/


var win= null;
function NewWindow(mypage,myname,w,h,scroll){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',toolbar=no,location=no,status=no,menubar=no,resizable=no,dependent=no'
win=window.open(mypage,myname,settings)
if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

// end script here-->

</script>



And here's the code which you can insert anywhere you want the "certificate" to show up. The page "mc_secure.html" referenced below is the popup page.


<script language="javascript">

<!--

if((location.href.substr(0,5)=='https')||(location.href.substr(0,5)=='HTTPS')) {
document.write('<a href="javascript:NewWindow(\'http://www.yourdomain.com/mc_secure.html\',\'\',\'475\',\'475\',\'yes\')">')
document.write('<img src="https://secure99f.monstercommerce.com/www_yourdomain_com/images/')
document.write('monster_commerce_secure.gif" width="125" height="40" border="1" ')
document.write('alt="Monster Commerce Secure Page" style="border-color:black;">')
document.write('</a>')

}

else if ((location.href.substr(0,5)=='http:')||(location.href.substr(0,5)=='HTTP:')) {

document.write('')

}

//-->

</script>



And here's the image I made. It's not as great as I wanted it, but it's not too terrible. Maybe the monstersmile.gif folks can come up with something better. biggrin.gif

user posted image

Finally, I imagine y'all will want to see the whole thing in action. Here's the checkout page at SoWhimsy.com - look in the lower right corner.

https://secure12b.monstercommerce.com/www_s...m/checkout1.asp

Hope y'all find this of some use!
danilyn22
Thanks. It looks awesome. I am going to give it a try!
liltricky
Thanks Tim! This is very clever!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.