I used jquery-1.8.0.min.js on my site and I need make redirect in some situations.
I was try this:
$('<div></div>').appendTo('body')
.html('<div><h4>Some text....</h4></div>')
.dialog({
modal: true,
title: 'Dialog title...',
zIndex: 10000,
autoOpen: true,
width: 'auto',
resizable: false,
draggable: false,
buttons: {
Ok: function () {
$(this).dialog("close");
var loc = window.location;
var currentURL = loc.protocol + '//' + loc.host + loc.pathname;
var newUrl = loc.protocol + '//' + loc.host + 'Account/LogOn?ReturnUrl=' + urlencode(currentURL);
$('<div style="dispaly:none;"></div>').appendTo('<body>').html('<a id="loginredirect" href="' + newUrl + ' "><br /></a>');
$('#loginredirect').click();
}
},
close: function (event, ui) {
$(this).remove();
}
});
but this doesnt work :-( so i try this:
$('<div></div>').appendTo('body')
.html('<div><h4>Some text....</h4></div>')
.dialog({
modal: true,
title: 'Dialog title...',
zIndex: 10000,
autoOpen: true,
width: 'auto',
resizable: false,
draggable: false,
buttons: {
Ok: function () {
$(this).dialog("close");
var loc = window.location;
var currentURL = loc.protocol + '//' + loc.host + loc.pathname;
var newUrl = loc.protocol + '//' + loc.host + 'Account/LogOn?ReturnUrl=' + urlencode(currentURL);
$(window.location).attr('href', newUrl);
}
},
close: function (event, ui) {
$(this).remove();
}
});
but this doesnt work too...
Any idea where is the problem?
Thanks
EDIT 1: If i was trying window.location.hrej = newUrl, FF ErrorConsole show me this: NS_ERROR_MALFORMED_URI: Component returned failure code: 0x804b000a (NS_ERROR_MALFORMED_URI) [nsIDOMLocation.href] in localhost/Content/scripts/jquery-1.8.0.min.js
and browser dont redirect to newUrl in IE, FF and Chrome...
locationobject is not a DOM element and you cannot convert it to a jQuery object.