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

Unclear value of button when being passed

In my Welcome.html file, I am attempting to send the value of a button to a function that simply logs that value. This function is located in a functions class that has been imported into my welcome.ts file. <ion-content padding id="page1"> <h1 ...

What are some techniques for concealing a CSS transition beneath another element in both directions?

Witness the magic in action! By clicking on the black box below, a larger black box will gracefully emerge from beneath the sidebar. While it may not be as clear in jsfiddle, rest assured that this effect is more pronounced in browsers. Thanks to some clev ...

Seeking guidance on implementing toggle buttons for navigation bar items on mobile screens, enabling them to toggle for a dropdown menu. The tools at my disposal are HTML, CSS

I want to make the navigation menu responsive by adding a toggle button for the dropdown menu on mobile screens. Here is the code snippet: .nav-link { display: inline-block; position: relative; color: black; } html,body{ height: 100%; width ...

Touchwipe incorporation - single-page website script

Today has been dedicated to troubleshooting and searching for a solution regarding the integration of TouchWipe () on a custom one-page-site script based on Parallax that I found perfect for my latest project (). The script itself performs beautifully wit ...

Limiting access to list views in Django admin interface

Imagine we have a model defined as follows: class Person(models.Model): name= models.CharField(max_length=100, blank=True) identity_number= models.IntegerField(unique=True) The name field should be accessible to the public, while the identity_num ...

Encountering difficulties with image file uploads in Django and AJAX due to CSRF issues

I experimented with Alex Kuhl's unique ajax script for uploading images to Django 1.4. The first thing that puzzles me is why I'm seeing a blank page and Firebug indicating an error: In my template html: $ is not defined element: $('#fil ...

Utilize SVG background with transparent text for a clear view of surrounding content

I'm looking for a way to overlay a video with a semi-transparent black div that includes text and a button, while still allowing users to see the video playing behind it. I previously achieved this using a PNG image but now need to apply the effect to ...

Toggle the status of active to inactive instantaneously with the click of a

Incorporating DataTables with ajax using PHP CodeIgniter Framework has presented me with a challenge. I am struggling to toggle between Active and Inactive buttons seamlessly. My desired outcome: When the Active button is clicked, it should transition ...

tap the hyperlink to complete the form and mimic the action of a designated

I'm working on an HTML form that includes a table and two submit buttons. <input type="image" name="button1" value="First Button" src="some_image.png"> <input type="image" name="button2" value="Second Button" src="some_image.png"> One ch ...

Using ChartsJs to visualize input data formatted in the German data format

I am relatively new to working with Charts.js, but I will need it to generate some visually appealing graphs for my website. In the background, I have a Django project running that calculates a specific set of numbers for me. Due to the language setting in ...

You do not have the authorization to access this content

I have been working on a Laravel web application to upload images into a data table and allow users to download the uploaded image on click. Initially, everything was working fine until I made changes in the code from return '{!! Html::link('ima ...

My webpage is experiencing issues with function calls not functioning as expected

I have created a select menu that is integrated with the Google Font API. To demonstrate how it works, I have set up a working version on JSBIN which you can view here. However, when I tried to replicate the code in an HTML page, I encountered some issues ...

Ways to navigate to a new page using jQuery Mobile

As a newcomer to jquery mobile, I am still learning how ajax handles page transitions, and I suspect the issue may be related to that. In my jqm / phonegap app, I have set up multiple pages. The homepage checks if the user is logged in by retrieving membe ...

Troubleshoot the issue of ng-click not functioning properly when used in conjunction with ng-repeat with direct expressions

Having some trouble with an ng-repeat block and setting a $scope variable to true with an ng-click expression. It doesn't seem to be working as expected. Can anyone help out? Check the plnkr for more information. HTML: selected: {{selected}} < ...

Can you provide some insight into why the init() method is throwing an error?

My project utilizes DynamoDB access through https://www.npmjs.com/package/react-native-dynamodb. I followed the code provided on the website for implementation. The issue I'm facing is that when hovering over my .init() method in WebStorm IDE, it sho ...

Automating the indexing of scroll positions in JavaScript

My code is functioning properly, but I had to input each case manually. Now, I am working on optimizing it to make it adaptable for any situation. However, I am struggling to figure out the best approach. The main objective is to determine my position on ...

Guide on performing calculations on a model attribute using input from a form in Django

Just starting out with Python/Django and putting in the effort to learn. Currently, I am developing a basic View that will: -take input from a form (DecimalField) -pass it to the View where calculations will be performed using my Class Method -displ ...

Troubleshooting: WordPress failing to launch Bootstrap Modal

I recently transformed my PHP website into a WordPress theme, but unfortunately, I am facing an issue with my Bootstrap modal not opening in WordPress. ***Header.php*** <a id="modal_trigger" href="#modal" class="sign-in-up"><i class="fa fa-user ...

Interacting between my React Native client and server.js

Currently, I am developing a project that utilizes react native, express, and MongoDB. My challenge lies in establishing communication between the react-native-js file and the node-js file. Specifically, when the submit button is clicked, I aim to pass a ...

Is there a way to verify if the jcrop widget (copping area) has been successfully initialized?

I am currently utilizing the library . This library provides four handlers to detect when a crop is activated, updated, changed, or removed. My task now is to determine when the cropping widget was initially created. However, I have noticed that there is ...