CSS Chapter 4 (1)
CSS Chapter 4 (1)
Data Unit - IV
• Apart from well-designed web pages with easily navigable layouts, learning about
users and using information gained about them is also very effective.
• Accessing the user’s local file system from a web application is pretty much off
limits because of security restrictions included in browsers.
• Cookie property of document object can be used to create and retrieve cookie
data from within a JavaScript code.
Prepared By: Khan Mohammed Zaid, Lecturer, Comp. Engg.,
3
MHSSP
Cooki
es stores in the visitor’s computer.
• Cookies are small text files that a browser
• Path: The path to the directory or web page that set the cookie.
• Secure: If this field contains the word "secure", then the cookie may only be
retrieved with a secure server. If this field is blank, no such restriction exists.
• Name=value: Cookies are set and retrieved in the form of key-value pairs
Prepared By: Khan Mohammed Zaid, Lecturer, Comp. Engg.,
5
MHSSP
Cooki
•Storing Cookies: es
• A cookie can be created by assigning string-value to the document.cookie
object.
• Cookie values may not include semicolons, commas, or whitespace. For this
reason, you may want to use the JavaScript escape() function to encode the
value before storing it in the cookie.
• where name is the name of the cookie and value is its string value.
• You can use strings' split() function to break a string into key and values
• If you have a page with no frames, there will be just one window object.
• However, if you have more than one frame, there will be one window object for
each frame.
where:
URL: specifies the URL of the page to open. If no URL is specified, a new
window/tab with about:blank is opened.
name: specifies the target attribute or the name of the window. Following
values are supported:
_blank: URL is loaded into a new window or tab.
_parent: URL is loaded into the parent window.
_self: URL replaces the current page.
_top: URL replaces any framesets that
may be loaded. name: The name of the window.
Prepared By: Khan Mohammed Zaid, Lecturer, Comp. Engg.,
12
MHSSP
Opening new
Windows
specs: A comma separated lists of items. E.g. fullscreen, height,width, left,
top, menubar, scrollbars, titlebar, toolbar.
replace: Specifies whether the URL creates a new entry or replaces the
current entry in the history list. (true/false)
• When you click same button multiple times to open a window, it will replace the
previous child window with a new window with overwritten data.(only 1 window
is visible)
• To open multiple windows from single button (keeping each child window), use
different window name for each click.(provide a rand number for window name)
• This method makes a request to bring the current window to the foreground.
Syntax: window.focus()
• moveto(x,y): moves a window’s left and top edge to the specified coordinates.
• scrollby()
• scrollto()
• For this method to work, the visibility property of the window’s scrollbar must be
set to true.
Syntax: window.scrollby(xnum,ynum)
Where:
xnum: how many pixels to scroll by, along x-axis. +ve value will scroll
to the right, - ve value will scroll to the left.
ynum: how many pixels to scroll by, along y-axis. +ve value will
scrolldown, - ve value will scrollup.
Syntax: window.scrollto(xpos,ypos)
Where:
xpos: The coordinate to scroll to along x-axis.
ypos: The coordinate to scroll to along y-axis.
• One-shot timer triggers just once after a certain period of time and second type
of timer continually triggers at set of intervals.
• Common uses for timers include advertisement banner pictures that change at
regular intervals or display the changing time in a web page.
Syntax: window.setTimeout(function,milliseconds);
Where:
function: it is a function you want to execute.
millisecond: millisecond delay until the code is executed.
Syntax: window.clearTimeout(timeoutVariable)
where:
timeoutVariable: it is the variable returned
from setTimeout() method.
• E.g. myVar = setTimeout(function, milliseconds);
clearTimeout(myVar);
Syntax: window.setInterval(function,milliseconds);
Where:
function: it is a function you want to execute.
millisecond: millisecond delay until the code is executed.
Syntax: window.clearInterval(timerVariable)
where:
timerVariable: it is the variable returned
from setTimeout() method.
• E.g. myVar = setInterval(function, milliseconds);
clearInterval(myVar);
• The history object is part of the window object and is accessed through the
window.history property.
• Property:
Length: Returns the number of URLs in the history list.
It returns atleast 1, because the list includes the currently loaded page.
Maximum length is 50.
This property is read-only.
Syntax: history.length
Prepared By: Khan Mohammed Zaid, Lecturer, Comp. Engg.,
40
MHSSP
Browser
• Methods:
History
back(): Loads the previous URL in the history list.
It is same as clicking the back button in a browser.
Syntax: history.back();