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

Bruce Gust
Bruce Gust used Ask the Experts™
Here's my code:

	$('#wellness_button').click(function(event) {
		var portal = $('#the_link').val();
		var bdg = $('#initials').val();
		var dbox = $('#decline');
		if(bdg=="") {
			alert("Don't forget to initialize the form.");
		else {
			if(':checked')) {
			else {

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 "," it appends that link to the existing url so it comes out ""

What am I missing?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2014
replace :
by :
window.location.href = portal;
or by :
location.href = portal;
Bruce GustPHP Developer


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!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial