473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

if Secure statement for https and http

I am trying to setup an html page. I have a button and when you click
on it I want it to go to either http:///.../demo.htm or
https://..../demo.htm based on whether or not you went through the
crypted site or the uncrypted site. I know that I can make a relative
address but since the link that I want is not on the same server I
can't do that. I just want a script that says

if secure
document.load "https:// this secure web address"
else
document.load "http://this non secure address"

I am new to programming and I would really appreciate any guidance.
Thanks.

Mar 27 '06 #1
8 2920
vandenberc wrote on 27 mrt 2006 in comp.lang.javascript:
I am trying to setup an html page. I have a button and when you click
on it I want it to go to either http:///.../demo.htm or
https://..../demo.htm based on whether or not you went through the
crypted site or the uncrypted site. I know that I can make a relative
address but since the link that I want is not on the same server I
can't do that. I just want a script that says

if secure
document.load "https:// this secure web address"
else
document.load "http://this non secure address"
if (/https:\/\//.test(location.href))
location.href = "https://blahblah.com/"
else
location.href = "http://blahblah.com/"

or shorter:

location.href = (/https:\/\//.test(location.href))
? "https://blahblah.com/"
: "http://blahblah.com/"
I am new to programming and I would really appreciate any guidance.


If you are so new to programming,
perhaps you should reconsider working on site security?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 27 '06 #2
Great. So what exactly do I put where it says
((/https:\/\//.test(location.href)) and in the ? and :
Thanks so much for your help.
location.href = (/https:\/\//.test(location.href))
? "https://blahblah.com/"
: "http://blahblah.com/"

Mar 27 '06 #3
The site I am going to is secure already I just need the button to link
to either the secure link or the nonsecure link based on if they typed
in http ot https....

Mar 27 '06 #4
vandenberc wrote on 27 mrt 2006 in comp.lang.javascript:
The site I am going to is secure already I just need the button to link
to either the secure link or the nonsecure link based on if they typed
in http ot https....


This is usenet, not email, so:
Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the article
headers. <http://www.safalra.com/special/googlegroupsreply/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 27 '06 #5
vandenberc wrote on 27 mrt 2006 in comp.lang.javascript:
location.href = (/https:\/\//.test(location.href))
? "https://blahblah.com/"
: "http://blahblah.com/"
Great. So what exactly do I put where it says
((/https:\/\//.test(location.href)) and in the ? and :
Thanks so much for your help.


Use the code as is!
Read up on regular expressions.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 27 '06 #6
Thank you for the tips.

Mar 28 '06 #7
vandenberc wrote on 28 mrt 2006 in comp.lang.javascript:
Thank you for the tips.


What tips?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 28 '06 #8
"vandenberc" <va********@telspan.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
Thank you for the tips.


Thank you for ignoring them.

Simon
--
http://urlkick.com/
Free URL redirection service. Turns a long URL into a much shorter one.
Mar 29 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Pooja Renukdas | last post by:
Hello, I have this web site where only two pages have to be secure pages and I need to call them using https, but since I have my development server and my production web server, I dont want to...
3
by: Vince Mele | last post by:
We are having a small problem with a couple of reports we developed for a client website. On two of the reports, sometimes (most of the time) we receive a warning message before the output of...
7
by: Brian Henry | last post by:
I created a project and it looks like everything is loading under HTTPS on all the pages perfectly except one page that it loads saying that the page contains both secure and non secure items......
1
by: Prabhu | last post by:
Hi. We have an ASP.net Web application in which some of the pages are to be served over secure channel using HTTPS. We have built a framework that allows pages to be served over secure channel...
3
by: Bill | last post by:
I'm running a C#.Net application that is using the HttpWebRequest to upload an xml file to a https site with FIPS complicancy turned on. On the "GetRequestStream()" method I get: "The underlying...
8
by: Daniel Crespo | last post by:
Hello everybody, I'm trying to implement a secure xmlrpc server with basis on http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496786 recipe. The thing that I'm concerned about is how can...
7
by: runner7 | last post by:
Can anyone tell me the easiest or best way to do secure server-to-server transmissions using PHP? Does SSL work for server-to-server? Thanks for any replies.
1
by: bizt | last post by:
Hi, I have a webpage where Im creating AJAX type requests by loading dynamic pages containg JavaScript into hidden iFrames. The reason I am opting for this method over XmlHttpRequest object...
0
by: Raven | last post by:
Hi, I have a problem with a server side redirect from a secure page to a non-secure page (same domain name, same folder) I have added some test code that can display the target URL and that...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.