Vefforritun 1 kennd haustið 2024
Has the page loaded yet? Did the HTTP request for the JavaScript succeed? Did the HTTP request for the JavaScript complete? Does the corporate firewall block JavaScript? Does their ISP or mobile operator interfere with downloaded JavaScript? Have they switched off JavaScript? Do they have add‐ons or plug‐ins installed which inject script or alter the DOM in ways you didn’t anticipate? Is the Content Delivery Network up?
Alveg eins og við aðskiljum útlit frá efni viljum við aðskilja forrit frá efni.
Tengt progressive enhancement er hugtakið unobtrusive JavaScript.
<a href="..." class="enhance" ">document.querySelector('enhance'). addEventListener('click', handleClick)1. Identify core functionality.
2. Make that functionality available using the simplest possible technology.
3. Enhance!
Some designers have misunderstood progressive enhancement to mean that all functionality must be provided to everyone. It’s the opposite. Progressive enhancement means providing core functionality to everyone. After that, it’s every browser for itself.
HostGET / HTTP/1.1
Host: example.org
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:93.0) Gecko/20100101 Firefox/93.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
HTTP/1.1 200 OK
Content-Encoding: gzip
Accept-Ranges: bytes
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
Date: Mon, 25 Oct 2021 08:39:07 GMT
Expires: Mon, 01 Nov 2021 08:39:07 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Vary: Accept-Encoding
Content-Length: 648
<html>
...
GET – biður um síðu, lang mest notaða aðferðin!POST – Biður server um að taka við gögnum í request sem nýrri einingu. T.d. nýtt svar við umræðuþræði eða ný gögn í gagnagrunniPUT, DELETE o.fl. notað í vefþjónustum, ekki á vefnumConnection: closeAccept – efnistýpur, content-types, sem eru samþykktar fyrir svarAccept-Charset – Charset sem eru samþykkt í svariHost – domain nafn sem beðið er umDate – Dagstími sem svar var sentServer – Nafn þjónsContent-Length – lengd svars í bætumContent-Type – MIME týpa efnis og stafasettÞegar þjónn svarar með response gefur hann upp stöðukóða, sem tölu og lesanlegan texta
1xx – Til upplýsinga2xx – Gekk, success3xx – Áframsending, redirection4xx – Villa hjá client5xx – Villa hjá server200 OK – staðlað svar fyrir HTTP request sem gengur upp201 Created – request gekk upp og ný auðlind var búin til301 Moved Permanently – þessi og allar frekari requests eiga að fara á nýtt URI400 Bad Request – Einhver villa í syntax hjá client404 Not Found – Fannst ekki en gæti birst í framtíðinni500 Internal Server Error – Almenn villahttp://example.org/example.html?start=true#kafli2URI, en í nýjum staðli er URL og URI það sama<form><form> getum við skilgreint hvort við notum GET eða POST með method attribute<form method="get"> sendir gögn með GET og setur allar breytur í query-string, t.d. http://example.org/?foo=bar<form method="post"> sendir gögn með POST og setur allar breytur í request body<form method="get"><form method="get" action="">
<label>
Nafn: <input type="text" name="name">
</label>
<button>Senda</button>
</form>
<form method="post"><form method="post" action="">
<label>
Name: <input type="text" name="name">
</label>
<button>Senda</button>
</form>