The browser's window.location.href fails to redirect the page

Here are my functions:

<a onClick="check_claims(this)"  type="button" href="javascript:void(0)" redirurl="www.facebook.com" >Invite</a>



function check_claims(ele){
    var select_claims = document.getElementById('select_claims').value;
    if (select_claims == '1') {
        var result = confirm("do you wish to continue?");
         if (!result) {
                 check_email_address();
                 return;
         }
    }
         check_email_address();
         window.location.href = ele.getAttribute('redirurl');
}


function check_email_address(){
    if ('{{broker.email_address}}' == 'None') {
        console.log('this worked till here');
        window.location.href = 'www.google.com';
    }
}

I have recently added the check_email_address function. It is being called and the log message is printed, but the window.location.href in this function is not recognized, and the page continues to redirect to the URL specified in the first function's window.location.href.

Answer №1

Utilize return false; at the conclusion of the handler.

For further information, you may check out this question.

UPDATE: Please give this a try.

function verify_claims(elem){
    var chosen_claims = document.getElementById('select_claims').value;
    if (chosen_claims == '1') {
        var outcome = confirm("Do you want to proceed?");
         if (!outcome) {
                 verify_email_address();
                 return;
         }
    }
         var email_verification = verify_email_address();
         if (!email_verification) window.location.href = elem.getAttribute('redirurl');
}


function verify_email_address(){
    if ('{{broker.email_address}}' == 'None') {
        console.log('up until here everything is functioning as expected');
        window.location.href = 'www.google.com';
        return true;
    }
    return false;
}

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

Transpiler failed to load

My Angular application running on Node has recently encountered a problem with the transpiler. I have been trying to load mmmagic to evaluate uploaded files, but encountered difficulties in the process. While attempting to update NPM packages, I gave up on ...

Using Array.push within a promise chain can produce unexpected results

I have developed a method that is supposed to retrieve a list of devices connected to the network that the client has access to. export const connectedDevicesCore = (vpnId: string, vpnAuthToken: string) => Service.listVPNConnectionsCore ...

Combining the inline JavaScript linting tool ESLint with the popular Airbnb configuration and Facebook

In my current project, I am utilizing ESLint and looking to incorporate Facebook flow. However, I am encountering warnings from ESLint regarding flow type annotations. Within the project root directory, I have both .flowconfig and .eslintrc files present. ...

The Firebase storage percentChanges() method is throwing a NaN error

I want to create a Firebase storage service using an Angular client to handle user profile image uploads. This service should return two observables: uploadProgress$ and downloadUrl$. The uploadProgress$ observable will store the value from percentChanges ...

Transmitting unique characters, such as a caron symbol, via xmlhttp.responseText and encoding them with json_encode

I am struggling to retrieve data from a database that contains a special character (caron) and then pass it through xmlhttp.responseText using json_encode to fill textboxes. However, the textbox linked to the data with the special character (caron) is not ...

"Ensuring Proper Validation for Forms with JavaScript: A Step-by-Step Guide

Here is a sample Javascript form: <form id="loginForm" name="loginForm" action="/create_session/" method="post">{% csrf_token %} <table border="0" cellpadding="0" cellspacing="0" id="id-form"> <tr> <th valign=" ...

Saving a variable's value using Knockout loop within an HTML document

As a newcomer to KO, I have been utilizing the following code in my HTML file to print a specific value: <!-- ko foreach: { data: JSON.parse($parent.options), as: 'option' } --> <!-- ko if: option.label === 'AAA' || option. ...

What is the reason behind the significant 80% reduction in PNG files by grunt-contrib-imagemin compared to the minimal reduction of less than 0.1%

Just getting started with Grunt here. Recently, I've been experimenting with grunt-contrib-imagemin. When it comes to compressing PNG files, it does an impressive job. It typically reduces the size by around 80%. However, I'm finding that the ...

The nodes.attr() function is invalid within the D3 Force Layout Tick Fn

I'm currently experimenting with the D3 Force Layout, and I've hit a roadblock when it comes to adding elements and restarting the calculation. Every time I try, I keep encountering this error: Uncaught TypeError: network.nodes.attr is not a fun ...

Refreshing a <div> element in Django, yet there is no visible update

As I utilize a barcode scanner to add objects to my array list, the data is populated after each scan depending on the scanning speed of the user. To exhibit this data, I have designed a dedicated page. My intention is to avoid refreshing the entire page b ...

What steps should I take to modify my database while utilizing radio buttons in the edit mode?

I am experiencing an issue with the radio button functionality. When creating a new user.jsp, I am able to successfully add the value from the radio button to the database. However, when I attempt to edit the values in the jsp, the changes do not reflect i ...

The process of loading the Facebook like script using $.getScript is causing an issue where the

How can I make the Facebook like button display properly on my HTML page? I have successfully loaded scripts and divs for Twitter, Google +1 buttons, but the Facebook like button script is not displaying the button. The alert shows that the script is exec ...

Establishing the focal point and emphasis within a textarea input field

I am presenting a textarea input through PHP with the following command : print " '<textarea rows='16' cols='30'>$flist'</textarea><BR>"; I want the textarea to receive focus and automatically select the co ...

Changing a button's value on click using PhoneGap

I've been working with phonegap and came across an issue with my buttons setup like this: <input id="my_button" type="button" onclick="my_function();"/> The goal is to capture the click event and change the button's value, my_function ( ...

Generating and Retrieving Dynamic URL with Jquery

My web page named single-colur.html has the ability to handle various query strings, such as: single-colour.html?id=1 single-colour.html?id=2 single-colour.html?id=3 single-colour.html?id=4 The parameter id in the URL corresponds to an entry in a table c ...

Jasmine spies falsely report the calling of functions when they have not actually been called

Below is the code snippet I am currently working with: $scope.deleteJob = function(job) { SandboxService.deleteJob(job.id).then(res => { if (res.status == 200) { ngToast.success(); $scope.refreshApps(); } ...

Creating specialized paths for API - URL handlers to manage nested resources

When working with two resources, employees and employee groups, I aim to create a structured URL format as follows: GET /employees List employees. GET /employees/123 Get employee 123. GET /employees/groups List employee groups. GET /employees/groups/123 ...

Determine the absolute path with respect to a different reference path, rather than the current working directory

One of the challenges I'm facing with my Node.js module is how to easily allow developers to edit the location of the dependencies relative to the module file itself. The issue arises because the current working directory, accessed through `process.cw ...

Access the Vue instance from a different element instance

I've developed a leaflet map using vue.js. There's a method I've created called 'showSubmit' that needs to be triggered on the leaflet marker moveend event. Here's what I'm currently doing: this.map.markers.user.on("move ...

Halt and anticipate a boolean reply from another function

Is there a way to create two functions in JavaScript, run one of them, then within that function, execute the other and pause until it receives a response (yes or no) before moving on to an if statement? The user's response should be manual. Here is ...