te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - document.location does not change the webpage in IE9? - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - document.location does not change the webpage in IE9? - Stack Overflow

programmeradmin3浏览0评论

I am trying to redirect to a different page in IE9 (9.0.3).

When I try to get/set document.location, or document.location.href, or window.location/window.location.href, I'm unable to do so. It fails without giving any errors.

I've tried to check whether the document and windows objects are set, and they are, so I have no idea why the location object is "missing".

I tried getting the document.URL and that works fine, but it's read-only.

Anyone know what the problem is or how to achieve this in a cross-browser way?

I am trying to redirect to a different page in IE9 (9.0.3).

When I try to get/set document.location, or document.location.href, or window.location/window.location.href, I'm unable to do so. It fails without giving any errors.

I've tried to check whether the document and windows objects are set, and they are, so I have no idea why the location object is "missing".

I tried getting the document.URL and that works fine, but it's read-only.

Anyone know what the problem is or how to achieve this in a cross-browser way?

Share Improve this question edited May 1, 2015 at 13:49 Eric Leschinski 154k96 gold badges422 silver badges337 bronze badges asked Nov 23, 2011 at 16:19 dgivonidgivoni 5552 gold badges7 silver badges17 bronze badges 2
  • I believe this will answer your question: stackoverflow./questions/7857878/… – Ivan Commented Nov 23, 2011 at 16:22
  • It works fine for here. Can you show some relevant code? – NullUserException Commented Nov 23, 2011 at 16:25
Add a ment  | 

5 Answers 5

Reset to default 8

I was also experiencing the same problem but found that adding

window.event.returnValue = false;

above line in the javascript before the redirection resolved the problem.

See this: http://social.msdn.microsoft./Forums/en/iewebdevelopment/thread/c864ae63-66f6-4656-bcae-86b0018d70c9

Apparently it's a caching bug, you can solve it by appending a timestamp to the destination URL (that is, using a "unique" URL every time).

Perhaps your IE9 has some security restrictions in place that prevent JavaScript from directing URL's. window.location.href = "" should work normally on IE9.

Cache may be the reason, try:

location.href='something.php?tmp=' + Date.parse(new Date())

Hope it helps

You should use an absolute URL:

var url = '/section/page/';
var host = window.location.hostname;
window.location = 'http://' + host + url;

Where url is the relative path to your page.

发布评论

评论列表(0)

  1. 暂无评论