简体   繁体   English

google +评论和javascript

[英]google+ comments and javascript

I'm working on a wordpress plugin that is supposed to add a google+ comments section next to an embedded video. 我正在开发一个wordpress插件,该插件应该在嵌入式视频旁边添加一个google +评论部分。 I can use javascript to get the correct width initially, but the scripts that auto load in the Iframe document automatically change the size to 100% width if the browser size is changed (see images). 最初,我可以使用javascript来获取正确的宽度,但是如果更改了浏览器的尺寸,则自动加载到iframe文档中的脚本会将尺寸自动更改为100%的宽度(参见图片)。 I am having serious difficulty accessing the div in the document under the Iframe to change its with to what I want when it resizes. 我很难访问iframe下文档中的div,以将其更改为调整大小时所需的格式。

how it should be. 应该如何。

after adjusting the browser size it jumps below and goes to 100% width. 调整浏览器大小后,它会跳到下方并达到100%的宽度。

I'm using thise code to generate the comments section: 我正在使用thise代码生成注释部分:

<script src="https://apis.google.com/js/plusone.js"></script>
<div id="comments"></div>
<script>
gapi.comments.render('comments', {
    href: [URL],
    width: 'comments_w',
    first_party_property: 'BLOGGER',
    view_type: 'FILTERED_POSTMOD'
});

"comments_w" is a variable that is calculated in an earlier javascript based on the space left after the video's width is calculated. “ comments_w”是一个变量,它是在较早的javascript中根据视频宽度计算后剩余的空间计算出来的。

this is the Iframe being gnerated inside the comments div 这是在评论div中生成的iframe

<iframe frameborder="0" hspace="0" marginheight="0" marginwidth="0" scrolling="no" style="position: static; top: 0px; width: 1138px; margin: 0px; border-style: none; left: 0px; visibility: visible; height: 616px;" tabindex="0" vspace="0" width="100%" id="I0_1480032087207" name="I0_1480032087207" src="https://apis.google.com/u/0/_/widget/render/comments?usegapi=1&amp;href=http%3A%2F%2Fwww.cellcycle.net%2Ftemppage%2F&amp;width=341&amp;first_party_property=BLOGGER&amp;view_type=FILTERED_POSTMOD&amp;origin=http%3A%2F%2Fwww.cellcycle.net&amp;search=&amp;hash=&amp;gsrc=3p&amp;jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en.CUXyo_wPfp0.O%2Fm%3D__features__%2Fam%3DAQ%2Frt%3Dj%2Fd%3D1%2Frs%3DAGLTcCMYqx5cA6SdMRKSM5YaRVPo-xpcPg#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled%2Cdrefresh%2Cerefresh%2Cscroll%2Copenwindow&amp;id=I0_1480032087207&amp;parent=http%3A%2F%2Fwww.cellcycle.net&amp;pfname=&amp;rpctoken=30831408" data-gapiattached="true" title="Comment on this"></iframe>
    #document == $0
        <html est...>
</iframe>

There is a div inside the body that controls the width. 主体内部有一个div来控制宽度。 I just need to find a way to access it with javascript and change the size whenever the browser is resized. 我只需要找到一种方法即可使用javascript访问它,并在每次调整浏览器大小时更改大小。 I already have the function I want being called whenever it is resized. 我已经有了想要在调整大小时调用的函数。 I am just having a hard time with getting jQuery to find the element inside the document. 我很难让jQuery在文档中找到元素。

Ok confirmed this is not possible. 确定,这是不可能的。 as Jaromanda X pointed out the origin must be the same. 正如Jaromanda X所指出的那样,原点必须相同。 I looked into origin policy here ( https://en.wikipedia.org/wiki/Same-origin_policy ) and found out for sure. 我在这里调查了原产地政策( https://en.wikipedia.org/wiki/Same-origin_policy )并确定地发现了这一点。 Kind of unfortunate for me, but hope this prevents anyone else from wasting time trying to. 对于我来说有点不幸,但是希望这可以防止其他人浪费时间尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM