Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从AMP iframe重定向顶级父AMP页面_Javascript_Html_Redirect - Fatal编程技术网

Javascript 从AMP iframe重定向顶级父AMP页面

Javascript 从AMP iframe重定向顶级父AMP页面,javascript,html,redirect,Javascript,Html,Redirect,我有一个AMP页面,它有一个iframe,其中包括一个带有标准javascript代码的标准html页面,我想要的是,当用户单击某个操作时,iframe会将顶级AMP页面重定向到指定的链接 这是我使用的AMP-pug模板: - var env = commentsData.env; - var domain = commentsData.domain; - var vfId = commentsData.vfId; - var redirectLink = `${commentsData.red

我有一个AMP页面,它有一个iframe,其中包括一个带有标准javascript代码的标准html页面,我想要的是,当用户单击某个操作时,iframe会将顶级AMP页面重定向到指定的链接

这是我使用的AMP-pug模板:

- var env = commentsData.env;
- var domain = commentsData.domain;
- var vfId = commentsData.vfId;
- var redirectLink = `${commentsData.redirectLink}#comments-section`;
- var url = `https://s2-${env}.${domain}/service/comments/comments-amp.html?id=${vfId}&redirectLink=${redirectLink}`;

amp-iframe.comments(
  height='500'
  sandbox='allow-top-navigation allow-scripts allow-same-origin allow-modals allow-popups allow-forms'
  frameborder='0'
  src=url
)
然后重定向的javascript就是

window.top.location.replace(redirectLink);
出于某种原因,我不明白它只是在iframe中重定向,而不是顶级AMP页面

有什么想法吗

谢谢