Meta refresh - Wikipedia

文章推薦指數: 80 %
投票人數:10人

Meta refresh is a method of instructing a web browser to automatically refresh the current web page or frame after a given time interval, using an HTML meta ... Metarefresh FromWikipedia,thefreeencyclopedia Jumptonavigation Jumptosearch Methodofinstructingabrowsertoautomaticallyrefreshawebpage HTML DynamicHTML HTML5 audio canvas video XHTML Basic MobileProfile C-HTML HTMLelement spananddiv HTMLattribute altattribute HTMLframe HTMLeditor Characterencodings namedcharacters Unicode Languagecode DocumentObjectModel BrowserObjectModel Stylesheets CSS Fontfamily Webcolors JavaScript WebGL WebCL W3C Validator WHATWG Quirksmode Webstorage Renderingengine Comparisons Documentmarkuplanguages Comparisonofbrowserengines vte Metarefreshisamethodofinstructingawebbrowsertoautomaticallyrefreshthecurrentwebpageorframeafteragiventimeinterval,usinganHTMLmetaelementwiththehttp-equivparametersetto"refresh"andacontentparametergivingthetimeintervalinseconds.ItisalsopossibletoinstructthebrowsertofetchadifferentURLwhenthepageisrefreshed,byincludingthealternativeURLinthecontentparameter.Bysettingtherefreshtimeintervaltozero(oraverylowvalue),metarefreshcanbeusedasamethodofURLredirection. Contents 1History 2Usability 3Examples 4Drawbacks 5Alternatives 5.1Forredirection 5.2Forrefresh 6References 7Externallinks History[edit] ThisfeaturewasoriginallyintroducedbyNetscapeNavigator1.1(circa1995),inaformofHTTPheaderandcorrespondingHTMLmetaHTTP-equivalentelement,whichallowsdocumentauthortosignalclienttoautomaticallyreloadthedocumentorchangetoaspecifiedURLafteraspecifiedtimeout.[1]Itistheearliestpollingmechanismavailablefortheweb[citationneeded],allowingausertoseethelatestupdateinafrequently-changingwebpage,suchasonesdisplayingstockpriceorweatherforecast. Usability[edit] UseofmetarefreshisdiscouragedbytheWorldWideWebConsortium(W3C),sinceunexpectedrefreshcandisorientusers.[2]Metarefreshalsoimpairsthewebbrowser's"back"buttoninsomebrowsers(includingInternetExplorer6andbefore),althoughmostmodernbrowserscompensateforthis(InternetExplorer7andhigher,MozillaFirefox,Opera,GoogleChrome). Therearelegitimateusesofmeta-refresh,suchasprovidingupdatestodynamicwebpagesorimplementingsitecontrollednavigationofawebsitewithoutJavaScript.Manylargewebsitesuseittorefreshnewsorstatusupdates,especiallywhendependenciesonJavaScriptandredirectheadersareunwanted. Examples[edit] Placeinsidethe

elementtorefreshpageafter5seconds: Redirecttohttps://example.com/after5seconds: Redirecttohttps://example.com/immediately: Drawbacks[edit] Metarefreshtagshavesomedrawbacks: Ifapageredirectstooquickly(lessthan2–3seconds),usingthe"Back"buttononthenextpagemaycausesomebrowserstomovebacktotheredirectingpage,whereupontheredirectwilloccuragain.Thisisbadforusability,asthismaycauseareadertobe"stuck"onthelastwebsite. Areadermayormaynotwanttoberedirectedtoadifferentpage,whichcanleadtouserdissatisfactionorraiseconcernsaboutsecurity.[3] Alternatives[edit] Metarefreshusesthehttp-equivmetatagtoemulatetheRefreshHTTPheader,andassuchcanalsobesentasaheaderbyanHTTPwebserver.AlthoughRefreshisnotpartoftheHTTPstandard,itissupportedbyallcommonbrowsers. HTTPHeaderexampleofaredirecttohttps://example.com/after5seconds: Refresh:5;url=https://www.example.com/ Alternativesexistforbothusesofmetarefresh. Forredirection[edit] AnalternativeistosendanHTTPredirectionstatuscode,suchasHTTP301or302.Itisthepreferredwaytoredirectauseragenttoadifferentpage.ThiscanbeachievedbyaspecialruleintheWebserverorbymeansofasimplescriptontheWebserver. JavaScriptisanotheralternative,butnotrecommended,becauseusersmighthavedisabledJavaScriptintheirbrowsers. ThesimplestwayofJavaScriptredirectusingtheonloadpropertyofthebodytag: Forrefresh[edit] Analternativemethodistoprovideaninteractiondevice,suchasabutton,tolettheuserchoosewhentorefreshthecontent.AnotheroptionisusingatechniquesuchasAjaxtoupdate(partsof)theWebsitewithouttheneedforacompletepagerefresh,butthiswouldalsorequirethattheuserenableJavaScriptintheirbrowser. YoucanrefreshawebpageusingJavaScriptlocation.reloadmethod.Thiscodecanbecalledautomaticallyuponaneventorsimplywhentheuserclicksonalink.Ifyouwanttorefreshawebpageusingamouseclick,thenyoucanusethefollowingcode :RefreshthisPage References[edit] ^"AnExplorationofDynamicDocuments".NetscapeCommunicationsCorporation.Archivedfromtheoriginalon2002-01-24.Retrieved2020-04-24. ^CoreTechniquesforWebContentAccessibilityGuidelines1.0-W3CNote6November2000 ^MetaRefreshTag,AnAbout.comarticlecoveringtheuseofthetagforpagereloadingorredirection Externallinks[edit] W3CWebContentAccessibilityGuidelines(1.0):Ensureusercontroloftime-sensitivecontentchanges metarefreshdeprecatedbyW3C Usestandardredirects:don'tbreakthebackbutton! H76:Usingmetarefreshtocreateaninstantclient-sideredirect JavaScriptPageRefresh Retrievedfrom"https://en.wikipedia.org/w/index.php?title=Meta_refresh&oldid=1106431841" Categories:HTMLHypertextTransferProtocolheadersHiddencategories:ArticleswithshortdescriptionShortdescriptionmatchesWikidataAllarticleswithunsourcedstatementsArticleswithunsourcedstatementsfromApril2020 Navigationmenu Personaltools NotloggedinTalkContributionsCreateaccountLogin Namespaces ArticleTalk English Views ReadEditViewhistory More Search Navigation MainpageContentsCurrenteventsRandomarticleAboutWikipediaContactusDonate Contribute HelpLearntoeditCommunityportalRecentchangesUploadfile Tools WhatlinkshereRelatedchangesUploadfileSpecialpagesPermanentlinkPageinformationCitethispageWikidataitem Print/export DownloadasPDFPrintableversion Languages ČeštinaEspañol한국어NorskbokmålRomânăСрпски/srpski Editlinks


請為這篇文章評分?