Ways to determine whether a website is operating on http or https protocol

There is a http call being made from my AngularJS application. I'm uncertain about the protocol used by the target website. Therefore, I need to determine whether the target site uses HTTP or HTTPS. Below is a snippet of my code.

var Path12 = "https://ABC.azurewebsites.net/XYZPage/XYZ_FUNCTION";
$http.get(Path12).success(function (data, status, headers, config) {
  var abc = "";
  var pqr = "";
}).error(function (data, status, headers, config) { });

I require assurance on whether ABC.azurewebsites.net operates using HTTP or HTTPS.

Answer №1

Learn how to create a hyperlink with JavaScript.

var Path12 = "https://ABC.azurewebsites.net/XYZPage/XYZ_FUNCTION";
var link = $document.createElement('a');
link.href = Path12;
console.log(link.protocol) //http:||https:

For more information, check out this resource: https://gist.github.com/jlong/2428561

Edit: Another way to create a link is by using the URL class.

var link = new URL(Path12)
{href: "https://abc.azurewebsites.net/XYZPage/XYZ_FUNCTION", origin: "https://abc.azurewebsites.net", protocol: "https:", username: "", password: ""…}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using PHP to output a string within a JavaScript onclick function parameter

I am attempting to display a string in PHP as a string variable within a JavaScript function, but it is not appearing correctly. How can I resolve this issue? <?php $example1 = "example 1"; $example2 = "example 2"; $examp ...

Using Angular 2 to assign a pipe dynamically from a variable

Could something like the following be achievable: {{property | some_variable_name}} I am aiming to utilize a pipe that is defined in a JSON configuration (or variable), but I am uncertain if it is feasible to include the pipe name within the interpolatio ...

Reset the AJAX object using jQuery

Currently, my code looks like this: object1 = $.ajax({ .. .. }); If an error occurs, I would like to have the ability to restart the ajax request. For instance, if the user's connection is lost, I want to be able to easily call the same ajax again w ...

Saving asp.net strings in different formats to datetime fields in a database

Can someone please assist me with saving the string value of textbox to the database as a datetime, and for updating/editing purposes, display it again in the textbox as a string? The reason for this is that the datetime input will be copied from Outlook a ...

Is your Vue.js chart malfunctioning?

I have been experimenting with chart.js and vue.js. The component I created is called MessageGraph, and it is structured like this (with data extracted from the documentation): <template> <canvas id="myChart" width="400" height="400">< ...

Firebase Error: The creator key was not defined, which cannot be passed as undefined in JSON. Instead, use null

Currently, I'm working on a project using angularFire 0.8.2. The project is actually based on thinkster.io's angular-firebase tutorial. However, I've encountered a hurdle when trying to create a custom user profile and access the data within ...

Is the custom search affecting the persistent state of AngularJS SmartTable? Potential scope-related issue

Utilizing AngularJS and SmartTable... I have successfully implemented a Persistent State that retains filters applied within the table. Recently, I added a custom search field for searching all columns, which also functions as intended. However, the filter ...

Side menu and grid display using HTML and CSS

Looking to revamp the layout of my angularJS website, specifically one page. Currently, information is displayed in a table format but I would like to switch it up by adding a left sidebar featuring a list of names (tiles). When a user clicks on a name, th ...

The validation of form.$invalid appears to be malfunctioning when using the Angular UI date picker

There are two fields on the form, one for selecting a due date and another for entering a number. The due date field is a date picker where you can choose a date or manually enter a number to set the date. The create button gets enabled only when setting ...

Enable scrolling for a div that contains ng-repeat items

Here is the HTML code snippet I am working with: <div id="header_context" class="scroll"> <div id="column_scroll" class="column" ng-repeat="column in columns track by column.name" ng-hide="column.name == 'date'" ng-click="column.vi ...

Animating a vertical line moving gracefully between two points

I am facing a challenge that requires your expertise. You may have come across an animated line resembling a scanner in various applications. I need something similar, but in the form of a graph. Specifically, I am looking to create a vertical line that a ...

Is there a way for me to use an ajax xmlhttprequest to submit all the selected values from my radio buttons?

Here's the situation: I have four input forms [A-D] and I have selected options A and B. I want to transfer this information to another page, but I'm not sure how to do it. I've tried searching for tutorials on AJAX, but most of them focus ...

AngularJS - utilize ngFilter to format input without modifying ngModel

Is it possible to apply a format filter on an input's text without affecting its model, and update the ngModel with the original value when the user changes the content in the input field? Here's what I mean... Let's consider this object: ...

What is the best way to utilize ajax for submitting and fetching content?

It's pretty obvious that I'm a complete novice when it comes to JavaScript and jQuery, but I have a query regarding ajax requests. Here's what I'm trying to achieve but struggling with: I've defined a content.append('<di ...

Use jQuery to smoothly scroll a div

I created a container using a <div> element which is divided into 3 inner divs. The first two inner divs are meant to serve as previous and next buttons, with ids of prev and next respectively. At the bottom, there are 3 more inner divs, each with un ...

JavaScript used for making an AJAX request

Currently, I am attempting to master the art of making an AJAX call using plain JavaScript with the goal of stepping away from JQuery for a specific project. However, I seem to be encountering a roadblock when it comes to xmlhttp.onreadystatechange. If a ...

Setting default values for route parameters in JavaScript

I'm looking to streamline my JavaScript code by simplifying it. It involves passing in 2 route parameters that are then multiplied together. My goal is to assign default values to the parameters if nothing is passed in, such as setting both firstnum ...

Utilizing jQuery to attach events to dynamically generated elements

I have a scenario where I am uploading multiple images and inserting them into specific div elements. These divs should toggle a class when clicked. Should I include the part of code that adds the onclick event inside the ajax success function? Your help i ...

Switching up the gameplay in Tic Tac Toe [The Odin Project]

Hello everyone, I have a question to ask and it's my first time here, so please forgive me if I make any mistakes! I've been learning to code with a resource called The Odin Project. Up until now, I've been able to tackle each project with ...

Attempting to capture a previously unhandled error thrown by Axios when utilized in conjunction with React Query (with suspense mode enabled) within a NextJs application

Utilizing NextJS, React query (with axios and suspense mode), I am attempting to handle an intentional 404 error from my API. Although I successfully caught it in my error.js file, the same error still shows up in the console as "uncaught." https://i.stack ...