Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

How can I get window.location to work...?

Here's my code:

	$('#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;
			}
		}
	});

Open in new window


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
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bruce Gust

ASKER

Hey, Leak!

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!