Sifr 和 Javascript 更改样式表(无需刷新页面)
我目前正在我的网站上使用 Sifr。 基本上我的页面顶部有一些彩色块,它们将根据您选择的颜色通过 JavaScript 更改样式表。 我想知道如何让 Sifr h1/h2 标签在单击时动态重新加载(无页面刷新) - 如果可能的话?
我尝试在 onclick 事件中添加 sIRF.activate 代码,也尝试将 sIFR.activate 代码放入 set_style 函数中,但无济于事。 如果有人能帮助我那就太好了!
干杯莉安
I'm currently playing around with Sifr on my site. Basically I have some coloured blocks at the top of my page, which will change the stylesheets through javascript, depending on the colours you chose. I would like to know how I can get the Sifr h1/h2 tags to reload dynamically (no page refresh) onclick - if that's possible?
I've tried to add the sIRF.activate code in the onclick event and I've also tried putting the sIFR.activate code inside the set_style function, but to no avail. If anyone can help me that would be fantastic!!
Cheers Leanne
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
给定 sIFR 3,可以更改一些用于呈现文本的 CSS。
我假设您有两个替换项,分别是
h1
和h2
,而我们只是更改它们的颜色:这应该会更改
和的文本颜色。 h1>
将元素替换为橙色。
sIFR.replacements[][]
返回的对象是 FlashInteractor s。Given sIFR 3, it is possible to change some of the CSS used to render the text.
I'm assuming you have two replacements, for
h1
andh2
, and we're only changing their color:This should change the text color of the
<h1>
and<h2>
replaced elements to orange.The objects returned by
sIFR.replacements[][]
are FlashInteractors.我自己没有使用过 sifr,但我认为最好的选择是 回滚插件。 然后,您应该能够通过回滚 & 有效地在 javascript 中重新加载 sifr'd 标签。 然后立即通过重新运行替换语句再次“前滚”(即基本上禁用并重新启用它)。
编辑:刚刚注意到此页面的底部有
redraw()
方法...实际上可能正是您所追求的? (再次,抱歉含糊不清,但我自己从未直接使用过 sifr)I haven't used sifr myself, but I think your best bet is the Rollback add-on. Then you should be able to effectively reload your sifr'd tags in your javascript by rolling back & then immediately "rolling forward" again by re-running your replacement statements (i.e. basically disabling & re-enabling it).
EDIT: Just noticed at the bottom of this page there's a
redraw()
method... might actually be exactly what you're after? (again, sorry for the vagueness, but I've never directly used sifr myself)