简体   繁体   English

如何在joomla按钮中添加onclick事件

[英]how to add onclick event in joomla button

if($this->params->get('show_cart_proceed',1)) {
  echo $this->cart->displayButton(JText::_(''),'checkout',$this->params,hikashop_completeLink('checkout'.$url_itemid),'');
}

I have this code for a checkout button in my site. 我的网站中有一个用于结帐按钮的代码。 How to add the onclick event in this? 如何在其中添加onclick事件?

Blocks of JavaScript code can be declared directly within a component or module's display template using the JDocument 可以使用JDocument在组件或模块的显示模板中直接声明JavaScript代码块

<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration('
    window.event("domready", function() {
        document.getElementById('buttonId').onclick = function () {};
    });
');
?>

or if you have external javascript then you can function there and import the script if you have not imported using 或者,如果您有外部javascript,则可以在那里运行并导入脚本(如果尚未使用导入)

<?php
$document = JFactory::getDocument();
$document->addScript('/media/system/js/sample.js');
?>

Refer document 参考文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM