Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何包括“;onclick”;在WordPressHTML中_Javascript_Html_Wordpress_Onclick - Fatal编程技术网

Javascript 如何包括“;onclick”;在WordPressHTML中

Javascript 如何包括“;onclick”;在WordPressHTML中,javascript,html,wordpress,onclick,Javascript,Html,Wordpress,Onclick,我在WordPress网站上使用“onclick”来触发事件。代码是: <a onclick="$zoho.salesiq.floatwindow.visible('show');"> [tt_vector_box icon="fa-comments" size="fa-4x" color="#FF8300" link_to_page="" target="" description=""] <h3>Customer Service</h3> Do you h

我在WordPress网站上使用“onclick”来触发事件。代码是:

<a onclick="$zoho.salesiq.floatwindow.visible('show');">
[tt_vector_box icon="fa-comments" size="fa-4x" color="#FF8300" link_to_page="" target="" description=""]
<h3>Customer Service</h3>
Do you have any questions?
Talk to our Live Help online service
[/tt_vector_box]
</a>

[tt#u vector_box icon=“fa comments”size=“fa-4x”color=“#FF8300”链接到_page=”“target=”“description=”“]
客户服务
你有什么问题吗?
请访问我们的在线帮助服务
[/tt_向量盒]
当试图保存代码时,WordPress会剥离onclick对象,留下:

<a>
[tt_vector_box icon="fa-comments" size="fa-4x" color="#FF8300" link_to_page="" target="" description=""]
<h3>Customer Service</h3>
Do you have any questions?
Talk to our Live Help online service
[/tt_vector_box]
</a>

[tt#u vector_box icon=“fa comments”size=“fa-4x”color=“#FF8300”链接到_page=”“target=”“description=”“]
客户服务
你有什么问题吗?
请访问我们的在线帮助服务
[/tt_向量盒]
我怎样才能解决这个问题

如果我必须编辑或添加代码,请告诉我在哪里添加或编辑代码,以及文件可能在哪里

感谢使用a在保存的帖子中实际包含js代码,或者如前所述,使用外部js文件并使用此外部文件中的代码以元素为目标(使用一些ID)

要使用快捷码,请执行以下操作:

// [onlick text="foo"]
function myonlick_func( $atts ) {
    $a = shortcode_atts( array(
        'text' => 'click here'
    ), $atts );

    return '<a onclick="$zoho.salesiq.floatwindow.visible(\'show\');">'.$a['text'].'</a>';
}
add_shortcode( 'onlick', 'myonlick_func' );
已编辑问题的更新:

短代码解析的Wordpress API不会解析嵌套的短代码(类似的),但可以解析不同的嵌套短代码(这是Wordpress中短代码的一个已知问题,各种插件和库使用自己的短代码解析方案来覆盖默认行为)

新问题的短代码解决方案是创建如下上下文短代码:

// [link_onlick][/link_onlick]
function myonlick_func( $atts, $content = '' ) {
    $a = shortcode_atts( array(
        'text' => 'click here'
    ), $atts );

    return '<a onclick="$zoho.salesiq.floatwindow.visible(\'show\');">'.do_shortcode( $content ).'</a>';
}
add_shortcode( 'link_onlick', 'myonlick_func' );
[link_onlick]
[tt_vector_box icon="fa-comments" size="fa-4x" color="#FF8300" link_to_page="" target="" description=""]
<h3>Customer Service</h3>
Do you have any questions?
Talk to our Live Help online service
[/tt_vector_box]
[/link_onlick]
/[link\u onlick][/link\u onlick]
函数myonlick_func($atts,$content=''){
$a=短码_附件(阵列)(
“文本”=>“单击此处”
)(港币),;
返回“”。do_短代码($content)。“”;
}
添加快捷码('link_onlick','myonlick_func');
这样使用:

// [link_onlick][/link_onlick]
function myonlick_func( $atts, $content = '' ) {
    $a = shortcode_atts( array(
        'text' => 'click here'
    ), $atts );

    return '<a onclick="$zoho.salesiq.floatwindow.visible(\'show\');">'.do_shortcode( $content ).'</a>';
}
add_shortcode( 'link_onlick', 'myonlick_func' );
[link_onlick]
[tt_vector_box icon="fa-comments" size="fa-4x" color="#FF8300" link_to_page="" target="" description=""]
<h3>Customer Service</h3>
Do you have any questions?
Talk to our Live Help online service
[/tt_vector_box]
[/link_onlick]
[link\u onlick]
[tt#u vector_box icon=“fa comments”size=“fa-4x”color=“#FF8300”链接到_page=”“target=”“description=”“]
客户服务
你有什么问题吗?
请访问我们的在线帮助服务
[/tt_向量盒]
[/link\u onlick]

这个新的短代码是自定义的,由您创建(默认情况下,它在wordpress中不存在)。新的短代码
[link\u onlick][/link\u onlick]
的代码可以放在您的wordpress functions.php文件中(该文件为您的wordpress站点定义自定义函数)

添加一个ID或类名,并从外部脚本将其作为目标。还有一个插件完全禁用wordpress自动格式化:@HaniSmith您自己制作,如果愿意,可以添加到functions.php文件中(查看wordpress教程链接),我在哪里可以找到wordpress快捷码?为了更清楚地了解这个问题,我改了帖子,请检查一下,告诉我应该怎么做。@HaniSmith所以你已经使用了一个(其他)短码,wordpress不会解析(类似的)嵌套短码,更新答案我不知道该怎么说Nikos。。。。非常感谢你。。。它正在工作yahaaaa:)@HaniSmith,太好了,如果你愿意,你也可以接受答案:)