HTML5
</style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script> $(function(){ function Mix(){} Mix.prototype={ OnStart: function(){ $('a:not(.no-load)').unbind().on("click",function(){ Mix.load($(this).attr('href')); return false; }) $('form:not(.no-submit)').unbind().on("submit",function(){ if($(this).attr('method')=='post'){ Mix.post($(this).attr('action'), $(this).serialize(), $(this)); }else{ Mix.load($(this).attr('action')+'?'+$(this).serialize()); } return false; }) Mix.PushWidth(location.href); }, load: function(url,script,popstate){ if(script==''){ script=''; } $.get(url) .done(function(data, status){ if(status=='success'){ Mix.OnDataPush(data, url, popstate); //Update HTML } if(script){ eval(script(data)); } Mix.OnStart(); }) .error(function(){ //Mix.OnStatus('Có lỗi trong việc tải trang hoặc có vẻ trang này không tồn tại.'); }) }, post: function(url, data, e, popstate){ $.post(url,data) .done(function(data, status){ if(status=='success'){ Mix.OnDataPush(data, url, popstate); } Mix.OnStart(); }) .error(function(){ Mix.OnStatus('Có lỗi trong việc gửi dữ liệu vui lòng thử lại.'); }) }, OnDataPush: function(html, href, popstate){ if(popstate!='OFF'){ Mix.UpdateURL($(html).filter('title').text(), href); } $('title').text($(html).filter('title').text()); $('.wcontainer').html($(html).filter('.wcontainer').html()); Mix.PushWidth(href); }, UpdateURL: function(title, url){ history.pushState('', title, url); }, PushWidth: function(href){ $('.wcontainer').removeClass().addClass('wcontainer'); if(href.match(/main\.php\?id\=reg/gi) || href.search(/main\.php\?id\=log/gi)){ $('.wcontainer').addClass('max-450') } console.log(href) } } Mix=new Mix(); Mix.OnStart(); $(window).bind('popstate',function(){ Mix.load(location.href.replace(location.origin,''),null,'OFF'); }) function rmAds(){ if($('iframe[src*="mobileweb.api.airpush.com"]').length>=0){ $('iframe[src*="mobileweb.api.airpush.com"]').remove() } setTimeout(function(){rmAds()}, 500); } rmAds() }) </script>
=))
Code này tối ưu không bị lỗi từ post tới get và load dữ liệu từ link.
Code này thì dán vào cuối ô http://wapego.com/css.php?v=2& ... _edit, http://wapego.com/css.php?v=1& ... _edit
Cám ơn, và điều cuối xóa hết iframe quảng cáo làm lag cả máy