当在CakePHP中添加'onmouseover'事件时,如何防止$ html-link()删除单引号? [英] How do I prevent $html-link() from removing the single quotes when adding an 'onmouseover' event in CakePHP?

查看:182
本文介绍了当在CakePHP中添加'onmouseover'事件时,如何防止$ html-link()删除单引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用onmouseover事件

Trying to use an onmouseover event

echo $html->link("Dashboard", 
     "/dashboard/index", 
     array("onmouseover" => "Tip('Test');") );

成为

<a href="/dashboard/index" onmouseover="Tip(&#039;Test&#039;);">Dashboard</a>

如何防止链接功能删除单引号?

How do I prevent the link function from removing the single quotes?



解决方案
Using Cake 1.2, this should definitely work:

echo $ html-> link('Dashboard','/ dashboard / index',
array(onmouseover=>Tip('Test');),null,false);

echo $html->link('Dashboard', '/dashboard/index', array("onmouseover" => "Tip('Test');"), null, false);

最后一个参数是转义选项。它默认为true。

The last parameter is the escape option. It defaults to true.

这篇关于当在CakePHP中添加'onmouseover'事件时,如何防止$ html-link()删除单引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆