function ResponsivePC(btnID, width, btnReturnID){ var self = this; this.width = width; this.nowWidth = $.cookie("viewportWidth"); this.btnReturnID = btnReturnID; this.changeWidth = function(event){ if (!this.nowWidth){ this.nowWidth = self.width; } $.cookie("viewportWidth", self.width); self.registReturn(); if (event.data){ location.href= '/'; }else{ $('meta[name=viewport]').attr('content','width=' + this.nowWidth); } } this.changeWidthReturn = function(event){ $(self.btnReturnID).css('display', 'none'); $.removeCookie("viewportWidth"); if (event.data){ location.href= '/'; }else{ $('meta[name=viewport]').attr('content','width=device-width, user-scalable=yes, maximum-scale=1.0, minimum-scale=1.0'); } } this.registReturn = function(){ if (self.btnReturnID){ $(self.btnReturnID).css('display', 'block'); $(self.btnReturnID).bind('click', true, this.changeWidthReturn); } } if (this.nowWidth){ this.changeWidth(false); this.registReturn(); } $(btnID).bind('click', true, this.changeWidth); }