Bruce Gust
asked on
How can I get window.location to work...?
Here's my code:
Everything is working great except for when my user gets to the last "else" clause and I want to redirect them to the url that's housed in the "portal" variable.
Instead of getting "https://the_new_link.com," it appends that link to the existing url so it comes out "https://my_current_page.net/%7Bhttps://the_new_link.com."
What am I missing?
$('#wellness_button').click(function(event) {
//alert("Yo");
var portal = $('#the_link').val();
var bdg = $('#initials').val();
var dbox = $('#decline');
if(bdg=="") {
alert("Don't forget to initialize the form.");
}
else {
if(dbox.is(':checked')) {
alert("wrong");
}
else {
//console.log(portal);
window.location=portal;
}
}
});
Everything is working great except for when my user gets to the last "else" clause and I want to redirect them to the url that's housed in the "portal" variable.
Instead of getting "https://the_new_link.com," it appends that link to the existing url so it comes out "https://my_current_page.net/%7Bhttps://the_new_link.com."
What am I missing?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I figured it out!
The URL that I was passing in as the "portal" value had a curly brace at the front and back end. I took a closer look at the bogus URL and noticed "%7B." I looked that up, recognized the character, adjusted the code and BOOM!
The sun is shining once again!
Thanks as always for weighing in!