View Single Post
ישן 22-03-08, 14:32   # 1
TheValley
חבר חדש
 
מיני פרופיל
תאריך הצטרפות: Feb 2008
הודעות: 21

TheValley לא מחובר  

תקלה עם STRINGS בJS

והגיע הזמן לתקלה היומית

החלטתי להוסיף SUBSTRING למאמרים בעמ' הראשי על מנת שלא תהיה הצפה של תוכן.
זה נראה בערך ככה:
PHP קוד:
<script>
var 
content "<%=r("article_content")%>";
var 
show content.substring(0,80) + "...";
document.write(show);
</script> 
והבעיה... יש לפעמים ירידת שורה בטקסט שמוחזר מהעורך WYSIWYG:
PHP קוד:
<script>
var 
content "
<p></p>
<p><font color="
#3366cc"><font color="#000000">asd</font></font></p>
<p><font color="#3366cc">Good afternooncpanel is now officialy working, new options will be added</font></font/></p>";
var show = content.substring(0,80) + "
...";
document.write(show);
</script> 
כמובן שJAVASCRIPT מתריע על סטרינג לא סגור

מה לעשות?!!!!??!!
  Reply With Quote