pringlesday
pringlesday

Reputation: 45

How do i make document.location.href behave like a simple link?

I have a select item with bunch of cities on my website. When the visitor selects some city this happens:

$("#city-selector").change(function() {
    var url = $(this).val(); // get selected value
    if (url) { // require a URL
        document.location.href = url; // redirect
    }
});

Each option inside the select has a value parameter that contains subdomain url in it. The problem is document.location.href doesn't behave like a simple link. It clears visitor id and it looks like the visitor doesn't have a referer and came to the new subdomain out of nowhere. Is there a problem with functions I use or should I dig into crossdomain sessions/cookies? How do I make it behave properly?

Upvotes: 0

Views: 175

Answers (1)

JJJJ
JJJJ

Reputation: 1338

Use window.location.href. This is similar when clicking a link

window.location.href = url;

Upvotes: 1

Related Questions