|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
缺乏可以共同遵循的行业标准,ASP还处在发展初期,大家对它的理解不同,如产品和服务标准,收费标准等,不利于行业的健康发展。按钮|扫瞄器Ihavehadalotofpeopleask,"HowtoIdisable?thebackbutton?"or,"HowdoIpreventauserfrom
clickingthebackbuttonandgoingbacktothepreviousscreen?"Infact,thisisoneofthemostcommonly
askedquestionsontheASPMessageboardand,sadly,theanswerisquitesimple:YouCANNOTdisabletheback
buttonofthebrowser.
InitiallyIcouldnotfigurewhyanyonewouldwantorneedtodothat.Thenitstruckmeastowhysomany
peoplewouldwanttodisablethebackbutton.(Nottheforwardbuttonmindyouonlythebackbutton.)When
ausersubmitsanapplicationandthengoesback"usingthebackbutton"tomakeachangeinsteadof
clickingon"Edit,"anewrecordwillbeinserted?wedontwantthat,nowdowe?Againiftheuser
finishedapageandthenwentbacktothatpageandcontinuedtomakechangesandsavedthemwewouldnot
wantthateither.
SoIdecidedtofigureawayorwaystopreventthisscenario.Istarteddoingabitofresearchallover
theNetgoingintovarioussitessobasicallythisarticlewillhavealotofstuffyoumighthavealready
readifyoulookedontheNet.Iamjusttryingtoputitallinoneplaceandfindthe"best"wayof
doingit!
OneofthemanysuggestionsIgotwastopreventthepagefrombeingcached.Thiscanbedonewithserver-
sidescript:
<%
Response.Buffer=True
Response.ExpiresAbsolute=Now()-1
Response.Expires=0
Response.CacheControl="no-cache"
%>
Thismethodworksgreat!Itforcesthebrowsertogototheservertogetthepageinsteadoffromits
cache.WhatyouwillwanttodoiscreateaSession-levelvariablethatdetermineswhetherornotauser
canstill"view"thepagethatyoudonotwanttolettheusernavigatebackto.Sincethepageisnot
beingcachedonthebrowser,thepagewillbereloadedwhentheuserhitsthebackbutton,andyoucan
checkforthatsession-levelvariabletoseeiftheusercanviewthispageornot.
Forexample,wecouldcreateaformlikeso:
<%
Response.Buffer=True
Response.ExpiresAbsolute=Now()-1
Response.Expires=0
Response.CacheControl="no-cache"
IfLen(Session("FirstTimeToPage"))>0then
Theuserhascomebacktothispageafterhavingvisited
it...wipeoutthesessionvariableandredirectthemback
totheloginpage
Session("FirstTimeToPage")=""
Response.Redirect"/Bar.asp"
Response.End
EndIf
Ifwereachhere,theusercanviewthepage,createtheform
%>
<formmethod=postaction="SomePage.asp">
<inputtype=submit>
</form>
NotethatweareusingaSessionvariable(FirstTimeToPage)tochecktoseeifthisistheusersfirst
visittothisparticularpage.Ifitisnt(thatis,ifSession("FirstTimeToPage")containsanyvalue),
thenweclearoutthesessionvariableandredirecttheuserbacktosomestartingpage.Now,whenthe
formissubmitted(andSomePage.aspisloaded),wemustsetthesessionvariableFirstTimeToPagetosome
value.So...inSomePage.aspwedneedcodelike:
Session("FirstTimeToPage")="NO"
Then,iftheuser,onSomePage.asp,hitsthebackbutton,thebrowserwillrequerytheWebserver,see
thatSession("FirstTimeToPage")containssomevalue,clearSession("FirstTimeToPage"),andredirectthe
usertosomepage.Allofthishinges,ofcourse,onthefactthattheuserhascookiesenabled,else
sessionvariableswontwork!(Formoreinformationonthissubject,besuretocheckouttheFAQ:For
sessionvariablestowork,musttheWebvisitorhavecookiesenabled?)
Youcanalsouseclient-sidecodetoforcetheusersbrowsertonotcacheaWebpage.
<html>
<head>
<metahttp-equiv="Expires"CONTENT="0">
<metahttp-equiv="Cache-Control"CONTENT="no-cache">
<metahttp-equiv="Pragma"CONTENT="no-cache">
</head>
Thereareacouplethingstokeepinmindwhenusingtheabovemethodtoforceabrowsertonotcachea
Webpage:
Pragma:no-cachepreventscachingonlywhenusedoverasecureconnection.APragma:no-cacheMETAtagis
treatediden</p>当然了,现在国内CRM厂商的产品与其说是CRM,但从至少从我的角度分析上来看,充其量只是一个大型的进销存而已了,了解尚浅,不够胆详评,这里只提技术问题 |
|