Beruflich Dokumente
Kultur Dokumente
ADVANCED STYLING
Mr. SAR Vathnak
June , 2018
PHNOM PENH INTERNATIONAL UNIVERSITY FACULTY OF SCIENCE AND INFORMATION TECHNOLOGY
OBJECTIVES
To use Ajax for turning a full website into a single-page app
To create a Back button with history using JavaScript
To save the app as an icon on the home screen
WHAT IS AJAX?
Ajax ( Asynchronous JavaScript and XML
[1]
):
refers to the technique of using JavaScript to send requests to a web server without
reloading the current page
Examples:
to retrieve some HTML,
to submit a form, etc.
[2]
By using Ajax, you could do the following tasks:
update a web page without reloading the page
request data from a server - after the page has loaded
receive data from a server - after the page has loaded
send data to a server - in the background
1 4
2
5
3
[1]
Disadvantages:
the browser will not give any indication of progress or errors to the users
(e.g. while sending/retrieving data to/from the server in the background)
the Back button will not work as expected (i.e., you have to do a lot of work to
create a much richer user experience with Ajax)
Later, we will use jQuery to “hijack” the onclick actions of the nav links,
so when the user clicks a link :
the browser page will not navigate to the target link.
Rather, jQuery will load a portion of the HTML from the remote page and
deliver the data to the user by updating the current page.
Re-arrange CSS file for android
Re-arrange CSS file for android
NOW EVERYTHING IS SET UP
This JavaScript loads a document called
index.html, and will not work without it.
However, none of the links in it will work unless the
targets of the links actually exist.
In my case, I duplicated code from index.html of
previous chapter, change the appropriate heading
titles, and rename as any sample files in the right
hand side.
PHNOM PENH INTERNATIONAL UNIVERSITY FACULTY OF SCIENCE AND INFORMATION TECHNOLOGY
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
Set the title variable to the HTML contents of the #content h2 element,
or to the string ‘Welcome to vREAD’ if there is no #content h2 element
ADVANCED STYLING PROGRAMMING MOBILE APPLICATIONS | BY SAR VATHNAK >> 10a
PHNOM PENH INTERNATIONAL UNIVERSITY FACULTY OF SCIENCE AND INFORMATION TECHNOLOGY
[1]
to this
SETTING THE PAGE TITLE
Change
To be more mobile-friendly, we’ll pull from title out of the content ( i.e.,
that this
#content h2 )
and put it in the header ( i.e, #header h1 JavaScript
) logical operator OR
Set the title variable to the HTML contents of the #content h2 element,
or to the string ‘Welcome to vREAD’ if there is no #content h2 element
ADVANCED STYLING PROGRAMMING MOBILE APPLICATIONS | BY SAR VATHNAK >> 10b
PHNOM PENH INTERNATIONAL UNIVERSITY FACULTY OF SCIENCE AND INFORMATION TECHNOLOGY
[1]
when click on
this link
previous version
Set the title variable to the HTML contents of the #content h2 element,
or to the string ‘Welcome to vREAD’ if there is no #content h2 element
ADVANCED STYLING PROGRAMMING MOBILE APPLICATIONS | BY SAR VATHNAK >> 10c
PHNOM PENH INTERNATIONAL UNIVERSITY FACULTY OF SCIENCE AND INFORMATION TECHNOLOGY
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]