Javascript accessing variable

I am using the folowing code (located in file swipe.js): $(document).ready(function() { $('.ui-slider-handle').live('touchstart', function(){ // When user touches the slider handle, temporarily unbind the page turn handlers doUnbind(); }); $('.ui-slider-handle').live('mousedown', function(){ // When user touches the slider handle, temporarily unbind the page turn handlers doUnbind(); }); $('.ui-slider-handle').live('touchend', function(){ //When the user let's go of the handle, rebind the controls for page turn // Put in a slight delay so that the rebind does not happen until after the swipe has been triggered setTimeout( function() {doBind();}, 100 ); }); $('.ui-slider-handle').live('mouseup', function(){ //When the user let's go of the handle, rebind the controls for page turn // Put in a slight delay so that the rebind does not happen until after the swipe has been triggered setTimeout( function() {doBind();}, 100 ); }); // Set the initial window (assuming it will always be #1 window.now = 1; //get an Array of all of the pages and count windowMax = $('div[data-role="page"]').length; doBind(); }); // Functions for binding swipe events to named handlers function doBind() { $('div[data-role="page"]').live("swipeleft", turnPage); $('div[data-role="page"]').live("swiperight", turnPageBack); } function doUnbind() { $('div[data-role="page"]').die("swipeleft", turnPage); $('div[data-role="page"]').die("swiperight", turnPageBack); } // Named handlers for binding page turn controls function turnPage(){ // Check to see if we are already at the highest numbers page if (window.now < windowMax) { window.now++ $.mobile.changePage("#page"+window.now, {transition: window.localStorage.getItem("transitionsSettings")}, false, true); } else { window.now= window.now-2; $.mobile.changePage("#page"+window.now, {transition: window.localStorage.getItem("transitionsSettings")}, false, true); } } function turnPageBack(){ // Check to see if we are already at the lowest numbered page if (window.now != 1) { window.now--; $.mobile.changePage("#page"+window.now, {transition: window.localStorage.getItem("transitionsSettings"), reverse: "true"}, true, true); } else { window.now = window.now+2; $.mobile.changePage("#page"+window.now, {transition: window.localStorage.getItem("transitionsSettings"), reverse: "true"}, true, true); } } I also have another file named loadFeed.js. They are both loaded inside index.html by this order: And here is the loadFeed.js file: google.load("feeds", "1"); alert(window.now); switch(now) { case 1: var link = "http://www.zive.sk/rss/sc-47/default.aspx"; var listviewID = "feedZive"; break; case 2: var link = "http://mobilmania.azet.sk/rss/sc-47/default.aspx"; var listviewID = "feedMobil"; break; case 3: var link = "http://www.automoto.sk/rss"; var listviewID = "feedAuto"; break; } alert(link); alert(listviewID); alert("#"+listviewID); function initialize() { var feed = new google.feeds.Feed(link); feed.setNumEntries(window.localStorage.getItem("entriesNumber")); feed.load(function(result) { if (!result.error) { var feedlist = document.getElementById(listviewID); for (var i = 0; i

以上就是Javascript accessing variable的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏