I have been trying to figure this out all afternoon, but have given up and now turning to you clever people to help :)
I have the following Jquery/Javascript function, which is working fine in Chrome - BUT in IE nothing happens?
$(".btnsubmitpost").click(function () {
var topicid = $(this).attr('rel');
var sbody = tinyMCE.get('txtPost').getContent();
$('.topicpostlistnewpost').remove();
$('.postsuccess').show();
$.post("/myurl/" + topicid + ".aspx",
{ "postcontent": sbody },
function (data) {
var returnUrl = $("value", data).text();
window.location.href = returnUrl;
return false;
});
return false;
});
I have tried window.location, window.location.href both with full urls and absolute Urls but IE just doesn't like it? Any ideas?
The function just gets a Url back from a post, and is supposed to redirect the user to the Url. But like I say, works in Chrome fine just not in IE (Tried IE8 and IE9)
Just for anyone having the same issue, the problem was because the window.location was inside the Ajax post method.
Just replace the window.location with a function() that then calls the window.location or do it after the Ajax call completely.
Related
I am currently facing issue with JS and IE compatibility.
I applied a new function in my webap in its JS part its working fine in IE11,Firefox and chrome but when the user access the site using IE9 some code wont work.
is there a way to fix this ?
I am always redirected to a blank page
Ive also tried using .replace and .assign and even
var url = 'link'
$(location).attr('href', url);
Ive already place a tag in my htm but still not working:
Any help or suggestion will be highly appreciated.
<meta http-equiv="X-UA-Compatible" content="IE9">
JS
$scope.isVerify = function ()
{
if (UserLevel == '0010')
{
window.location.href = 'mailto:?subject='' + '&body='';
return false;
}
else {
$window.location.href = $scope.details.(returntoprevpage)
}
};
As per checking the issue is not on the windows.location it appears that the issue we on the email body which pass the allowable length on IE9
I am able to create a work around using iframe
This does not work in Safari and Chrome:
$(".myButton").click(function(){
window.location.href('www.blahblahblah.com');
});
what's the solution?
window.location.href is not a function and therefor you cannot call it, you can however assign a value to it: (Also you should be using http:// when redirecting to another domain)
$(".myButton").click(function(){
window.location.href = 'http://www.blahblahblah.com';
});
EDIT: Corrected my first statement and added the part about http://
Had a similar problem. In chrome, return false; solved the problem.
if(confirm('Are you sure you wish to delete this order?'))
{
location.href='delete_order.asp?id=20'; **return false;**}
else
{return false;}
The above code works in Chrome and IE9
window.location.assign('http://www.google.com')
is the function you're looking for.
It's the equivalent of
window.location = 'http://www.google.com';
I am trying figure out how to refresh page in Safari (5.1) using javascript and nothing seems to work.
So far, I have tried,
window.location.href = window.location.href
window.location = window.location.href
window.location.reload(true)
window.location.replace(window.location.href)
What is the right way of handling page refresh in Safari?
Apparently, Safari on Mac or iOS has a bug with location.reload, so, I've developed this simple cross browser solution taking advantage of the url query string:
function refresh() {
var url = location.origin;
var pathname = location.pathname;
var hash = location.hash;
location = url + pathname + '?application_refresh=' + (Math.random() * 100000) + hash;
}
location.reload(true); // works for safari
If you didn't know already this site, let have a look on it, you will have a lot of example for refreshing page: http://www.quackit.com/javascript/javascript_refresh_page.cfm
You should always use the reload() method from the location object...
window.location.reload();
Set the first argument to true if you want to hard reload (send a new GET request for the page).
I need to export data in excel file.I am using JSON post for the same.Its working fine in every browser except IE. Have a look at my javascript code as follow:-
function ExportQueryData() {
var Qry = $("#txtQueryInput").val();
if ($.trim(Qry) == "") {
$("#txtQueryInput").addClass("error");
return false;
}
else
$("#txtQueryInput").removeClass("error");
var url = "/Reports/ExportQueryData";
var frmserialize = $("#frmQuery").serialize();
$.post(url, frmserialize, function(data) {
data = eval("(" + data + ")");
if (data.Success) {
url = "/Reports/Export";
var win = window.open(url, "DownloadWin", "resizable=0,status=0,toolbar=0,width=600px,height=300px");
win.focus();
win.moveTo(100, 100);
return false;
}
else {
Notify("DB Query", data.Message);
}
});
}
As per above code, i am calling /Reports/Export action using window.open. This pop up getting open for every browser except IE. In IE pop up get close simultaneously in 1 or 2 seconds.
I need to use JSON post because it validate input and then returns success status.I can validate my data only at server side.
Let me know if any information is missing here.
Your suggestion will be valuable for me.
Thanks.
I think you've got a pop up blocker situation... Frankly, I don't think opening up stuff in a pop up is a good idea anymore. Browsers seem to hate it.
You could instead show the user a link to the file, asking him to click to download.
I'm trying to make a request using prototype 1.6.1 on ie 8, the following code works on Firefox:
var myForm = document.forms[0];
myForm.request({
onSuccess:
function(transport) {
var url = getPath() + nomeAcao+'?modulo='+modulo;
window.location = url;
}
});
When debugging, i get an error on the "myForm.request" line, it says i can't call this method on this object. Anyone knows how to fix it?
instead of
myForm.request(...);
try
Form.request(myForm, ...);