location.href在IE9和Chrome中不起作用. [英] location.href is not working in IE9 and Chrome.

查看:96
本文介绍了location.href在IE9和Chrome中不起作用.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试修改URL(查询字符串参数)并重定向到javascript中的同一页面(在按钮单击事件中).
我已经尝试过
1.window.location.href = finalURL;
2.window.location.replace(finalURL);
3.$(location).attr(''href'',finalURL);
4.window.open(finalURL,``_self'');
它可以在Firefox中运行,但在IE9,Chrome中无法运行.
在IE9中,Chrome返回了页面,但是带有修改查询字符串参数的新URL没有反映出来.是否有任何适用于IE和Chrome的解决方案?

I am trying to modify the URL (query string parameter) and redirect to same page in javascript(In button click event).
I have tried
1.window.location.href = finalURL;
2.window.location.replace(finalURL);
3.$(location).attr(''href'', finalURL);
4.window.open(finalURL, ''_self'');
It work in Firefox, but nothing work in case of IE9,Chrome.
In IE9,Chrome the page is post back but the new URL with modify Query string parameters is not reflecting.Is there any solutions which work for IE and Chrome ?

Thanks in advance.

推荐答案

(location).attr(''href'',finalURL);
4.window.open(finalURL,``_self'');
它可以在Firefox中运行,但在IE9,Chrome中无法运行.
在IE9中,Chrome返回了页面,但是带有修改查询字符串参数的新URL没有反映出来.是否有任何适用于IE和Chrome的解决方案?

预先感谢.
(location).attr(''href'', finalURL);
4.window.open(finalURL, ''_self'');
It work in Firefox, but nothing work in case of IE9,Chrome.
In IE9,Chrome the page is post back but the new URL with modify Query string parameters is not reflecting.Is there any solutions which work for IE and Chrome ?

Thanks in advance.



请尝试此代码
hi
Please Try This Code
location.assign('YourUrl');


window.location = newUrl;


window.location = newUrl;


<html>
<head>
</head>
<body>
	<input type="button" value="Visit thread" onclick="window.location = 'http://www.codeproject.com/Questions/407140/location-href-is-not-working-in-IE9-and-Chrome';"/>
</body>
</html>


这篇关于location.href在IE9和Chrome中不起作用.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆