下面的代码应该将文本区域附加到 div 上,div 的内容进入文本框(<?php echo $section[foo]; ?>
部分)。主要和侧边栏部分按预期工作,但 3 页脚部分会抛出一条Uncaught SyntaxError: Unexpected token ILLEGAL
消息。它们使用完全相同的代码,除了 PHP 数组名称(完全复制 + 粘贴)。有任何想法吗?
<script>
function textarea(location,text)
{
window.alert(location);
var textarea=document.createElement("textarea");
var node=document.createTextNode(text);
textarea.appendChild(node);
var element=document.getElementById(location);
element.appendChild(textarea);
}
</script>
<div id="main">
<span onclick="textarea(this.parentNode.id,'<?php echo htmlentities($section['main']);?>');" class="edit"><img src="images/edit.png" alt="Edit" /> Edit Section</span>
<?php echo $section['main']; ?>
</div>
<div id="sidebar">
<span onclick="textarea(this.parentNode.id,'<?php echo htmlentities($section['sidebar']);?>');" class="edit"><img src="images/edit.png" alt="Edit" /> Edit Section</span>
<?php echo $section['sidebar']; ?>
</div>
<div id="left_column">
<span onclick="textarea(this.parentNode.id,'<?php echo htmlentities($section['footer_left']);?>');" class="edit"><img src="images/edit.png" alt="Edit" /> Edit Section</span>
<?php echo $section['footer_left']; ?>
</div>
<div id="right_column_outer">
<div id="right_column_left">
<span onclick="textarea(this.parentNode.id,'<?php echo htmlentities($section['footer_middle']);?>');" class="edit"><img src="images/edit.png" alt="Edit" /> Edit Section</span>
<?php echo $section['footer_middle']; ?>
</div>
<div id="right_column_right">
<span onclick="textarea(this.parentNode.id,'<?php echo htmlentities($section['footer_right']);?>');" class="edit"><img src="images/edit.png" alt="Edit" /> Edit Section</span>
<?php echo $section['footer_right']; ?>
</div>
</div>
完整的数组。我没有在此处编写 HTML 标记(生成 NicEdit)
array(5) {
["footer_left"]=>
string(365) "<h2 class="article">About</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sed justo in quam scelerisque pellentesque. Suspendisse erat tellus, sagittis eu venenatis non, eleifend vel arcu. Sed tempus magna sit amet nisi euismod ac cursus turpis faucibus. In eget nulla quam. Donec sagittis facilisis leo at porta. In libero lorem, aliquet vel vehicula a, fringilla ut odio. Praesent tincidunt porta hendrerit. Donec interdum augue eu nunc elementum bibendum. Etiam feugiat rhoncus quam, quis tincidunt justo imperdiet non. Donec bibendum congue arcu. Cras sollicitudin turpis ut tellus vehicula non ornare leo consectetur. Suspendisse dignissim faucibus felis non tempor. Mauris venenatis lorem in turpis facilisis tincidunt. Proin gravida, quam id ultrices ullamcorper, augue dolor porta massa, iaculis rhoncus felis purus quis diam. Morbi ultrices ultricies ipsum id placerat."
["footer_middle"]=>
string(424) "<h2 class="article">Location</h2>
<iframe id="location_map" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=narre+warren&aq=&sll=-37.916385,145.019321&sspn=0.057691,0.132093&ie=UTF8&hq=&hnear=Melbourne+Victoria,+Australia&t=m&z=13&ll=-38.027115,145.30304&output=embed"></iframe>"
["footer_right"]=>
string(294) "<h2 class="article">Contact</h2>
<strong>Skype:</strong> <a href="skype:sample?call">sample</a><br />
<strong>Phone Number:</strong> 999999999<br />
<strong>Email:</strong> <img id="email_address" src="images/email.png" alt="Email Address" />"
["main"]=>
string(66) "<b>Hello. </b><i>This is sam </i><u>Testing this website </u>"
["sidebar"]=>
string(721) "<blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><div style=\"text-align: right;\"><h5><span style=\"font-family: \'courier new\'; font-size: xx-large;\">This should all be right aligned.d</span></h5></div></blockquote></blockquote><blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><div style=\"text-align: right;\"><h5><span style=\"font-family: \'courier new\'; font-size: xx-large;\">I don\'t think lists work.</span></h5></div></blockquote></blockquote></blockquote>"
}
先感谢您。
编辑:这是jsfiddle > 它现在按预期工作(单击“编辑部分”,它应该提醒您父 div id 是什么,然后添加一个包含该 div 内容的文本框)我'已经取出 PHP ...我想知道为什么这在我的网站中不起作用。