Next things to be learnt
Geolocation
Okay Geolocation as well as being Javascript also will require some html coding.
That is for example is as Follows
- <p id="Mypos"></p>
- <button onclick="getMyPosition()">Find Me</button>
Do this without the bulletpoints Naturally
localStorage
Okay this is one bit of scripting that I am going to include here as well as test it out on this page with
me placing it in the head of the page.
<script>
if (typeof (Storage) !== "undefined") {
//we can accept localStorage
alert('Accepted');
} else {
//We cannot accept localStorage
alert('No localStorage accepted');
}
</script>
Okay it works and those of you viewing this page should have received a notification saying ocwd.mmcbride.co.uk Accepted
and only after accepting the dialog it should have loaded the Page. Now to store the information in the browser
using local storage we ad a script as such
<script>
localStorage.myName = "Michael McBride"
</script>
To Acces this we use the following script
<script>
alert(localStorage.myName);
</script>
This should Now pop up 2 alerts. one with My name and the Accepted Alert. How this would function in a real world case I do not know
But it will be fun Finding out some time.
sessionStorage
sessionStorage is different from localStorage in the fact that localStorage remains until it is cleared from the users cache or another
script terminates it. this script has to be from the same website that created it. now sessionStorage just hangs around until the window closes
You use the same script to tell the user that it can use sessionStorage with the same localstorage Script mentioned before
the following code is used for sessionStorage is as Follows
<script>
sessionStorage.myName = "Michael McBride"
</script>
To Access the sessionStorage the code is as follows
<script>
document.write(sessionStorage.myname);
</script>
This is definately not a short page as I am going to have to do a Javascript for testing on a new Page. so Click here to continue