Javascript 更改url后,chrome无法获取top.document
我没有使用任何插件或框架 我有一些本地帮助页面(不在服务器上托管),其中大部分需要加载到框架中。因此,在Javascript 更改url后,chrome无法获取top.document,javascript,google-chrome,Javascript,Google Chrome,我没有使用任何插件或框架 我有一些本地帮助页面(不在服务器上托管),其中大部分需要加载到框架中。因此,在onload过程中,我检查页面是否在框架中: top.document.location.href == document.location.href 如果这是真的,因此页面不在框架中,那么我 top.document.location.href = "frame.html?info="+document.location.href; 现在,当加载frame.html?info=stuff
onload
过程中,我检查页面是否在框架中:
top.document.location.href == document.location.href
如果这是真的,因此页面不在框架中,那么我
top.document.location.href = "frame.html?info="+document.location.href;
现在,当加载frame.html?info=stuff.html
时,我可以从以下位置获取info
参数:
`top.document` or `window.top.document`
并按预期将该页面加载到框架中
这一切都可以在Safari、IE9和Opera上正常工作。它在Chrome中不起作用。相反,加载frame.html后,top.document
和window.top.document
都是undefined
当我加载frame.html?info=…
如果有帮助,我相信这种行为是因为。你能事先将位置存储在变量中吗?@dave--当我加载新页面(top.document.location.href=…)时,我会丢失变量吗?你能事先将位置存储在变量中吗?@dave--当我加载新页面(top.document.location.href=…)我不会丢失变量吗?