运行 sifr 而不刷新页面?
是否可以使 sifr 重新运行或再次更新而无需刷新页面?
我想象有一个像 sifr() 这样的函数或其他东西..?
is it possible to make sifr re-run or update again without having to refreshing the page??
Id imagine there is a function like sifr() or something..?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
哪个版本的 sIFR?至少 sIFR 3 有一个方法:
Which version of sIFR? At least sIFR 3 has a method for this:
您说得对:有一个函数,称为 sIFR()。
Javascript 替换语句可以添加到 sifr.js 文件中,或者添加到 (X)HTML 文件的末尾。
当您将替换代码放入 sIFR Javascript 文件中时,它将在 onload 时执行(取决于 sIFR.bAutoInit 是否设置为 True,这是默认值)或当您调用 sIFR() 时。如果将替换语句放在正文中,它们将立即执行。
实际上,这意味着您可以将替换语句放入 JavaScript 中并在正文中调用 sIFR()。这不会有任何区别。
为了节省带宽,您可以将替换语句放在 JavaScript 文件中,然后在正文中调用 sIFR()。在这种情况下,您必须在正文中使用的确切代码是:
显然,您可以稍后再次调用此函数,例如,当某些内容异步更改时。
旁注:我不知道西蒙选择的 redraw() 函数。显然,如果我在的话,我会尝试一下。
You are spot on: There is a function, called sIFR().
The Javascript replacement statements can be added in the sifr.js file, or at the end of your (X)HTML file.
When you put the replacement code in the sIFR Javascript file, it’ll execute on onload (depending on if sIFR.bAutoInit is set to True, which is the default value) or when you call sIFR(). If you put the replace statements in the body, they'll be executed immediately.
Effectively, this means that you could put the replacement statement in the JavaScript and call sIFR() in the body. It won't make any difference.
To save bandwidth you can put the replace statements in the JavaScript file, and then call sIFR() in the body. The exact code you have to use in the body in this case is:
Obviously you could call this function later again, e.g when something has changed asynchronously.
Sidenote: I wasn't aware of the redraw() function opted by Simon. Obviously I would give that a go, if I where you.
谢谢你们。不幸的是我的版本是2.0.7。我必须让前端设计师知道更新 sifr 以适应未来的标记。我没有时间再玩这个了,因为该项目还有更重要的事情。
我尝试了整个 sIFR() 方法,但没有用,看起来每次用户切换主题时都必须刷新页面。或者,如果我有时间接近尾声,我会将其更新为 v3 并尝试 redraw()。
thanks guys. unfortunately for me its version 2.0.7. I'll have to let the front end designers know to update sifr for future markups. I havnt got time to play with this anymore as there is more important things on the project.
I tried the whole sIFR() thing, but didn't work, looks like ill have to refresh the page everytime the user switches themes. Or if i get time towards the end ill update it to v3 and try the redraw().