0

我创建了一个页面来显示新闻并添加了一些 javascript,它工作正常。但是当我在我的页面中添加一些越南语内容时,javascript 不再起作用了。如何解决这个问题?好的,这是我的html

.row
  .span7.offset2
    .box-model-news
      .row  
        .span3
          %h5
            = @news[0].title
      .row.hot_news
        - 3.times do |i|
          .span2
            - if @news.length > i+1  
              .fixed-box
                = image_tag @news[i+1].asset.url(:small)
              %h6
                = link_to @news[i+1].title, "#"
  .span3
    .box-model-news
      - rest_news = @news[4..@news.length-1]
      - if rest_news
        - rest_news.each do |rn|
          = link_to rn.title,"#"

和javascript:

= javascript_tag do
  :erb
    alert("hi");

@news[0].title : 标题包含一些越南语单词

html代码

<div class="row">
<div class="span7 offset2">
<div class="box-model-news">
<div class="row">
<div class="newest-news">
<div class="span3">
<img alt="375649_373983335965607_104188519611758_1224852_274911402_n" src="/system/bbook_news/assets/000/000/011/medium/375649_373983335965607_104188519611758_1224852_274911402_n.jpg?1351583899">
</div>
<div class="span3">
<h5>
<a href="#">Vietnamese word: Xin Chào mọi người</a>
</h5>
</div>
</div>
</div>
<div class="row hot_news">
<div class="span2">
<div class="fixed-box">
<img alt="301806_293504937402115_112083275544283_698768_1122549180_n" src="/system/bbook_news/assets/000/000/012/small/301806_293504937402115_112083275544283_698768_1122549180_n.jpg?1351584751">
</div>
<h6>
<a href="#">Không chạy được </a>
</h6>
</div>
<div class="span2">
<div class="fixed-box">
<img alt="380269_296696787082930_112083275544283_706587_1195153490_n" src="/system/bbook_news/assets/000/000/013/small/380269_296696787082930_112083275544283_706587_1195153490_n.jpg?1351584787">
</div>
<h6>
<a href="#">fala</a>
</h6>
</div>
<div class="span2">
<div class="fixed-box">
<img alt="402580_344754638902723_100001045697946_1105971_1493945266_n" src="/system/bbook_news/assets/000/000/014/small/402580_344754638902723_100001045697946_1105971_1493945266_n.jpg?1351584806">
</div>
<h6>
<a href="#">yeah~!</a>
</h6>
</div>
</div>
</div>
</div>
<div class="span3">
<div class="box-model-news more-news">
<ul>
<li>
<a href="#">21212121</a>
</li>
<li>
<a href="#">So?</a>
</li>
</ul>
</div>
</div>
</div>

javascript代码与上面的相同 alert("hi")

4

1 回答 1

0

在大多数情况下,无法运行 JS 是由于语法错误。

检查您的 javascript 控制台是否有任何错误消息

于 2012-10-30T09:51:33.783 回答