添加到<正文>cakePHP 应用程序的标签正文>
我有一个应用程序,我需要在两个表单的BODY标签的onLoad事件中调用一些JS。但是,我找不到如何修改它们的标签。有谁知道吗?
坦率
I have an app where I need to call some JS in the onLoad event of the BODY tag of two forms. However, I can't find how to modify the tag for just them. Does anyone know?
Frank
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
inkedmn 当然为这种情况提供了正确的答案,但一般来说,您可以像这样“传递信息”:(
在views/controller/view.ctp中)
(在views/layouts/default.html中) ctp)
我经常像这样使用它来向“顶级元素”添加额外的类:
inkedmn certainly has provided the right answer for this case, but in general, you can "hand information up" like this:
(in views/controller/view.ctp)
(in views/layouts/default.ctp)
I often use it like this to add extra classes to a "top level element":
您无需修改 body 标记即可在页面加载时执行 Javascript。您可以在适当的情况下在布局中包含类似的内容:
(jQuery)
或者,如果您希望在 document.ready 事件触发时执行代码:
或者,如果您不想使用 jQuery,您可以执行某些操作像这样:
祝你好运 - 如果这个答案不令人满意,请澄清你的问题。
You don't need to modify the body tag to have Javascript execute when the page loads. You could just include something like this in your layout where appropriate:
(jQuery)
Or, if you want to have the code execute when the document.ready event fires:
Or, if you don't want to use jQuery, you could do something like this:
Good luck - and please clarify your question if this answer isn't satisfactory.
我执行以下操作:
我们在我的身体中应用 $ bodyLoad
已经在我的 [action] 中。 Ctp,我执行以下操作:
如果您愿意,您也可以将此代码放入控制器中。
祝你好运
I do the following:
We apply $ bodyLoad in my body
Already in my [action]. Ctp, I do the following:
If you want you can also put this code in the controller.
Good luck