ASP网站制作之多种屏障扫瞄器的前进按钮的办法
缺乏可以共同遵循的行业标准,ASP还处在发展初期,大家对它的理解不同,如产品和服务标准,收费标准等,不利于行业的健康发展。按钮|扫瞄器Ihavehadalotofpeopleask,"HowtoIdisable?thebackbutton?"or,"HowdoIpreventauserfromclickingthebackbuttonandgoingbacktothepreviousscreen?"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,但从至少从我的角度分析上来看,充其量只是一个大型的进销存而已了,了解尚浅,不够胆详评,这里只提技术问题 用户端的浏览器不需要提供任何别的支持,这样大提高了用户与服务器之间的交互的速度。 我可以结合自己的经验大致给你说一说,希望对你有所帮助,少走些弯路。 还有如何才能在最短的时间内学完?我每天可以有效学习2小时,双休日4小时。 在平时的学习过程中要注意现学现用,注重运用,在掌握了一定的基础知识后,我们可以尝试做一些网页,也许在开始的时候我们可能会遇到很多问题,比如说如何很好的构建基本框架。 交流是必要的,不管是生活还是学习我们都要试着去交流,通过交流我们可以学到很多我们自己本身所没有的知识,可以分享别人的经验甚至经历。 我认为比较好的方法是找一些比较经典的例子,每个例子比较集中一种编程思想而设计的。 学习是为了用的,是为了让你的程序产生价值,把握住这个原则会比较轻松点。除此之外,课外时间一定要多参加一些社会实践活动,来锻炼自己的能力。 如何更好的使自己的东西看上去很不错等等。其实这些都不是问题的实质,我们可以在实践中不断提升自己,不断充实自己。
页:
[1]