2014-07-22 132 views
0

我正在制作一个像小提琴那样的编辑器,并且我处于早期阶段。我的JavaScript内置函数不起作用。Html实体解码方法

HTML代码

<div class="hello"> 
    <p>here is a paragraph</p> 
</div> 
<div class="content-placeholder"></div> 
<div class="hello123"> 
    <a href="#" onclick="myFunction();">Click here!</a> 
</div> 

JavaScript代码:

function myFunction(){ 
    alert('u r here'); 
} 

当我张贴这种形式预览包含HTML和JavaScript我的模板。一切似乎工作正常,但JavaScript不起作用,当我点击检查元素在浏览器中看到我的代码时,javascript函数消失,而不是这个<a href="#" onclick="myFunction">Click here!</a> 我得到像<a href="#">Click here!</a> onclick方法消失。 我正在使用html_entities_decode方法,同时在控制器中发布我的HTML。我正在使用codeigniter框架。

+0

这此代码必须是与笨消毒后的数据。你能否展示你如何检索你的代码中的发布数据? – budwiser

+0

$数据=阵列( \t \t \t \t “USER_ID”=> $ USER_ID, \t \t \t \t 'TEMPLATE_NAME'=> $这个 - >输入 - >交的( '模板名'), \t \t \t \t 'template_type'=> $ this-> input-> post('template_type'), \t \t \t \t'wp_tmp_html'=> htmlentities($ this-> input-> post('wp-html-code')), \t \t \t \t'wp_tmp_css'=> htmlentities($ this-> input-> p OST( 'WP-CSS代码')), \t \t \t \t 'wp_tmp_js'=>ヶ辆($这 - >输入 - >交的( 'WP-JS-代码')) \t \t);这是我如何张贴到控制器的数据阵列 –

回答

0

删除;您onclick..copy字符以下

<div class="hello"> 
    <p>here is a paragraph</p> 
</div> 
<div class="content-placeholder"></div> 
<div class="hello123"> 
     <a href="#" onclick="myFunction()">Click here!</a> 
</div>