Javascript在页面上加载项目时出错

时间:2013-09-18 16:24:14

标签: javascript jquery

我的网站上有两个错误,我认为问题在于javascript。我有firebugs插件显示这两个错误和代码,但我不知道如何解决它。

参数列表

之后

SyntaxError:missing)

window.Templates['home'] = _.template('<% if (loggedInUser == null){ %><% } %><div id="home_container">  <div id="home_title">--- is back!</div>  <div id="home_description">Created by music lovers, for music lovers.</div>  <div id="home_header">    <div class="home_header home_header_on"><a href="/explore">Search</a><span> all your favorites</span></div>    <div class="home_header"><a href="#">Share</a><span> songs with friends</span></div>    <div class="home_header"><a href="/trending">See </a> <span>What's </span> <span>Trending</span></div>  </div>  <div id="home_description"> --- is the best way to find and share music online</div>   <div id="home_search_container">    <form id="home_search_form">      <input id="home_search" class="large_input_text" placeholder="Search music" type="text" />      <input id="home_search_button" type="button" value="search" />      <span id="home_search_bg"></span>    </form>  </div>  <div id="home_share" class="hidden">    <div id="home_share_wrapper"> <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="lala" data-related="----:The best place for music on the web">Tweet</a>      <div id="fb-root"></div>      <div class="fb-like" data-send="false" data-layout="button_count" data-width="95" data-show-faces="true"></div>      <g:plusone size="medium"></g:plusone>    </div>  </div>  <div class="clear"></div></div><div id="home_footer_container"></div><body background="http://www.----.com/assets/images/testbg.jpg">');

另一个错误是箭头指向的位置 ReferenceError:未定义模板

var SongView = Backbone.View.extend({
    showAvatar: true,
    user: null,
 ->   template: Templates.common_songs,
    tagName: "div",
    className: "song_row a_song",
    events: {
        "click .song_view_love": "onLovedClicked",
        "click .song_view_share": "onShareClicked",
        "click .song_view_play_button": "onPlayButtonClicked",
        "click .song_view_queue": "onQueueClicked"
    }

这是固定的。但是修复window.Templates js导致new(Type Error:be is undefined),如下所示。有什么想法吗?

Zc.prototype.Ga=function(a){var b=a[0],c=window;c.google_unique_id?++c.google_unique_id:c.google_unique_id=1;b.cb=c.google_unique_id;this.f.U&&(P(this,"hxva",1),O(this,"cmsid",this.f.H),O(this,"vid",this.f.I));isNaN(this.f.Da)||P(this,"pod",this.f.Da);isNaN(this.f.Ea)||P(this,"ppos",this.f.Ea);isNaN(this.f.r)||P(this,"scor",this.f.r);N.prototype.Ga.call(this,a);a=window;var b=a.document.domain,d=a.document.cookie,e=a.history.length,f=a.screen,g=a.document.referrer,k=Math.round((new Date).getTime()/

2 个答案:

答案 0 :(得分:3)

在你的第一个例子中,你有一个'

window.Templates['home'] = _.template('<% i<snip>...span>What's
                                                             ^

即终止_.template('内的字符串,删除'from What's并尝试

答案 1 :(得分:0)

第二个错误是由第一个错误引起的。

如果你查看你发布的内容的结尾,语法突出显示会发现它因为URL中的“//”而将其视为注释。

<body background="http://www.----.com/assets/images/testbg.jpg">');

你需要逃避斜杠。