ASP.NET iframe:将元标记放置在父框架中
我有一个带有 iframe 的页面,根据我在 iframe 内的操作,我需要在 iframe 的父级上放置一个元标记。我怎样才能在代码后面做到这一点。我所拥有的是这样的,但元标记放置在 iframe 内。
// code behind of the iframe where I created a meta tag and placed it on the page.
HtmlMeta meta = new HtmlMeta();
meta.Name= "Keywords";
meta.Content = "some keywords i created based on the event of iframe.";
this.Header.Controls.Add(meta);
不幸的是,元标记放置在 iframe 内部,我想将其放置在 iframe 的父级上。
I have a page with an iframe in which depending on my action inside the iframe, I need to put a meta tag on the parent of the iframe. How can I do this in code behind. What i have is like this but the meta tag is placed inside the iframe.
// code behind of the iframe where I created a meta tag and placed it on the page.
HtmlMeta meta = new HtmlMeta();
meta.Name= "Keywords";
meta.Content = "some keywords i created based on the event of iframe.";
this.Header.Controls.Add(meta);
Unfortunately, the meta tag is placed inside the iframe, I want to put it on the parent of the iframe.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无法从 iframe 中页面后面的代码访问父页面。您必须为此使用客户端脚本。
不过,使用客户端脚本添加元标记的用处有限。例如,使用客户端脚本设置关键字对 SEO 没有影响。
It's not possible to access the parent page from the code behind of the page in the iframe. You have to use client script for that.
Adding meta tags with client script has limited usefulness, though. Setting the keywords using client script has for example no effect for SEO.
你可以使用jquery
you can use jquery for that