谷歌朋友群 + CSS 样式切换
我一直在我的博客 www.whataboutki.com 上尝试 CSS 样式切换,并且还添加了 Google 朋友群。 我现在想在用户更改样式时更改 GFC 小部件的颜色。 这是 GFC 的脚本... div id="div-1229769625913" 这是否意味着我可以从我的 css 文件访问它? 如果是这样,我将如何去做呢?
<!-- Include the Google Friend Connect javascript library. -->
<script type="text/javascript" src="http://www.google.com/friendconnect/script/friendconnect.js"></script>
<!-- Define the div tag where the gadget will be inserted. -->
<div id="div-1229769625913" style="width:260px;border:1px solid #cccccc;"></div>
<!-- Render the gadget into a div. -->
<script type="text/javascript">
var skin = {};
skin['HEIGHT'] = '385';
skin['BORDER_COLOR'] = '#cccccc';
skin['ENDCAP_BG_COLOR'] = '#e0ecff';
skin['ENDCAP_TEXT_COLOR'] = '#333333';
skin['ENDCAP_LINK_COLOR'] = '#0000cc';
skin['ALTERNATE_BG_COLOR'] = '#ffffff';
skin['CONTENT_BG_COLOR'] = '#ffffff';
skin['CONTENT_LINK_COLOR'] = '#0000cc';
skin['CONTENT_TEXT_COLOR'] = '#333333';
skin['CONTENT_SECONDARY_LINK_COLOR'] = '#7777cc';
skin['CONTENT_SECONDARY_TEXT_COLOR'] = '#666666';
skin['CONTENT_HEADLINE_COLOR'] = '#333333';
google.friendconnect.container.setParentUrl('/' /* location of rpc_relay.html and canvas.html */);
google.friendconnect.container.renderMembersGadget(
{ id: 'div-1229769625913',
site: '10794935298529647173'},
skin);
</script>
I have been playing around with CSS Style Switching on my blog www.whataboutki.com and have also added Google Friend Connect. I would now like to change the colours of the GFC widget when the user changes styles. This is the script for GFC... the div id="div-1229769625913" does that mean I can access that from my css files? If so how would I go about doing so?
<!-- Include the Google Friend Connect javascript library. -->
<script type="text/javascript" src="http://www.google.com/friendconnect/script/friendconnect.js"></script>
<!-- Define the div tag where the gadget will be inserted. -->
<div id="div-1229769625913" style="width:260px;border:1px solid #cccccc;"></div>
<!-- Render the gadget into a div. -->
<script type="text/javascript">
var skin = {};
skin['HEIGHT'] = '385';
skin['BORDER_COLOR'] = '#cccccc';
skin['ENDCAP_BG_COLOR'] = '#e0ecff';
skin['ENDCAP_TEXT_COLOR'] = '#333333';
skin['ENDCAP_LINK_COLOR'] = '#0000cc';
skin['ALTERNATE_BG_COLOR'] = '#ffffff';
skin['CONTENT_BG_COLOR'] = '#ffffff';
skin['CONTENT_LINK_COLOR'] = '#0000cc';
skin['CONTENT_TEXT_COLOR'] = '#333333';
skin['CONTENT_SECONDARY_LINK_COLOR'] = '#7777cc';
skin['CONTENT_SECONDARY_TEXT_COLOR'] = '#666666';
skin['CONTENT_HEADLINE_COLOR'] = '#333333';
google.friendconnect.container.setParentUrl('/' /* location of rpc_relay.html and canvas.html */);
google.friendconnect.container.renderMembersGadget(
{ id: 'div-1229769625913',
site: '10794935298529647173'},
skin);
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我首先尝试看看
div-1229769625913
是否在页面之间发生变化。 如果没有,那么您可以在 CSS 文件中重新设置样式,否则您将必须在样式切换器(我假设是 JS)中更改skin
的颜色。I'd experiment to see if
div-1229769625913
changes between pages first. If it doesn't then you could restyle in your CSS files, otherwise you will have to change the colours forskin
in your style-switcher (which I assume is JS).ID 由 GFC 生成。 它使用在其 *.gmodule.com 服务器上托管您的小工具代码的 iFrame 填充 DIV
理论上,您可以在加载后访问和修改其 DOM 以更改其样式
尝试更改“皮肤”映射中的样式值,例如
。 皮肤['ALTERNATE_BG_COLOR'] = '#ffffff';
祝你好运!
The ID is generated by GFC. It populates the DIV with an iFrame hosting your gadget code on their *.gmodule.com servers
In theory you could access and modify their DOM after it's loaded to change their style
Try changing the values in the "skin" map for style
eg. skin['ALTERNATE_BG_COLOR'] = '#ffffff';
Good luck!
页面之间的 div id 保持不变,但它会生成一个 iframe,并且 GFC 小工具显示在该 iframe 中。 您的 CSS 样式表无法控制该 iframe 内容的样式,因此实现此目的的唯一方法是使用一些 javascript。
最简单的解决方案是删除该哈希中的所有值,并在渲染小工具之前,根据当前使用的样式表替换任何合适的值。 这样你就不必弄乱 iframe 的 DOM,这将是不平凡且不可靠的脆弱,因为 Google 不希望你这样做。
所以你的代码可能看起来像这样:
The div id stays the same between pages, however, it generates an iframe and the GFC gadget is displayed within that iframe. Your CSS stylesheets don't have any control over the styling of the contents of that iframe, so the only way to accomplish this would be with some javascript.
The simplest solution would be to rip out all of the values in that hash, and prior to rendering the gadget, substitute whatever values are appropriate based on the currently used stylesheet. That way you don't have to mess with the DOM of the iframe, which would be non-trivial and unreliably fragile, since Google doesn't expect you to do this.
So your code might look something like this: