changes of context (and other uses of scripts)

Hi,

I looked at some types of things that JavaScript can do in order to see
1. if we want to ban them (under certain circumstances), and
2. if they fit into the definition the definition of "change of context", 
or if we want to change the definition to make these things fit, or if the 
issue is handled somewhere else.

Below is just a list of things I found and which can feed into the 
discussion on changes of context.


1. There are three types of popups that are custom-made for JavaScript use:
  - alert [e.g. alert("You have 30 seconds left.");]
  - confirm [e.g. confirm("Do you want more time?");]
  - prompt [e.g. prompt("Do you want more time?", 'Type number of seconds 
here');]
Like other JavaScript methods, these three methods can be used to create 
popups that the user did not request.


2. JavaScript to open a new (browser) window; syntax:
variableName = window.open("URL", "windowName", 
"option1=value,option2=value,...");
Each of the three arguments can be an empty string.
The options are things like height, width, resizable, menubar, status, ... 
[1] [2].
According to "Professional JavaScript" [3]:
"Security issues prevent you from changing the decoration of an already 
open window (unless you use a secure script), or a window displaying pages 
from a different web site."


3. In addition to adding or changing strings of text in an HTML document, 
JavaScript also can be used to write all the HTML code of a document in a 
pop-up window or a frame. This is often done with simple 
"document.write(...)" calls even though this is not DOM compliant (we 
currently have no success criterion on using JavaScript or anything else 
according to specific standards).
This content can be written to a pop-up window or to a frame.
An example of writing to a pop-up window:

<script type="text/JavaScript">
var newWindow = null
function seeColor(form) {
         newColor = 
(form.colorsList.options[form.colorsList.selectedIndex].value)
         if (newWindow == null) {
                 newWindow = 
window.open("","","HEIGHT=300,WIDTH=250,RESIZABLE=yes,STATUS=no,MENUBAR=yes")
         }
         newWindow.document.write('<html><body style="background-color:' + 
newColor + '">')
         newWindow.document.write('<h1>Colorpicker<\/h1><h2 
style="color:white">Colorpicker<\/h2><p>text<\/p><p 
style="color:blue">color for links<\/p><p style="color:red">color for 
active links<\/p><p style="color:#FF00FF">color for visited 
links<\/p><\/body><\/html>')
         newWindow.document.close()
         newWindow.focus()
}
</script>

<form action="">Pick a background color:
<select name="colorsList" onchange="seeColor(this.form)">
   <option selected="selected" value="">Kleur - hex RGB</option>
   <option value="aliceblue">Alice Blue - FOF8FF</option>
   <option value="antiquewhite">Antique White - FAEBD7</option>
   <option value="aqua">Aqua - 00FFFF</option>
   <option value="aquamarine">Aquamarine - 7FFFD4</option>
   <!-- many more colors -->
</select>
</form>
[There is an example at http://purl.org/NET/error404/kleuren.htm ; it is in 
Dutch: select a color from the drop-down list next to "Kies een 
achtergrondkleur:" at the top of the page.]

An example of writing to a frame (can be used for client-side search engines):
if you have a top frame with the search form (+ JavaScript code) and a 
bottom frame where you want to write the search results:

var docObj = parent.frames[1].document;
docObj.open();
docObj.writeln('<html><head><title> ...');
/* ... */
/* code adding <body> with search resuls ... */
docObj.writeln('<\/body></html>');
docObj.close();
[There is an example at http://purl.org/NET/error404/zoek.htm ; it is in 
Dutch; "zoeken" means "search"; you can test it by entering "javascript", 
"scripting", "search engine" and other web-related terms. The code is 
adapted from 'JavaScript Application Cookbook' by Jerry Bradenbaugh 
(O'Reilly, 1999; see also http://www.oreilly.com/catalog/jscook/index.html 
where you can download the chapter with this code).]



4. JavaScript can also be used to write complete frameset code. See for 
example the Joust Outliner [4], which is inaccessible for screenreader 
users. This contains code like

   self.document.writeln('<frameset cols="100%" rows="115" ...');

and does not validate (because the there is no frameset element until the 
JavaScript has written the code).

5. "JavaScript tooltips" [5]


6. Many download sites start an automatic download that starts a few 
seconds after opening the actual download page; this page usually contains 
a link that you can use if the script does not work in your browser.
Examples:
- http://download.zonelabs.com/bin/updates/znalm/za60667000AEN1023_UK.html 
: following the link "Download my ZoneAlarm update" opens a web page and a 
"Save as ..." dialog box (if you use IE you first get a warning that some 
downloads can harm your computer);
- SourceForge.net downloads use a similar mechanism; try for example the 
download links at 
http://sourceforge.net/project/showfiles.php?group_id=2238&package_id=151275&release_id=324310
- 
http://www.softpedia.com/progDownload/Javascript-Menu-Master-Download-1428.html 
starts an automtic download after 3 seconds
- code for automatically downloading a JVM if the user doesn't have one is 
at http://www.mozilla.org/docs/web-developer/upgrade_2.html#Deprecated_Applet
- PHP code (=server side) that is also supposed to start automatic 
downloads: 
http://www.sitepoint.com/forums/showthread.php?s=13c6dd62323b162017e7b7c50ac702ee&p=2154526#post2154526




[1] Microsoft's documentation: 
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp
[2] Gecko DOM Reference: 
http://www.mozilla.org/docs/dom/domref/dom_window_ref76.html
[3] Nigel McFarlane et al: "Professional JavaScript" Birmingham, UK: Wrox, 
1999.
[4] http://www.ivanpeters.com/
[5] DHTML JavaScript Tooltips by Walter Zorn: 
http://www.walterzorn.com/tooltip/tooltip_e.htm
and many other examples you can find by searching Google: 
http://www.google.be/search?hl=en&safe=off&q=%22Javascript+tooltips%22&btnG=Search&meta=


Regards,

Christophe Strobbe


-- 
Christophe Strobbe
K.U.Leuven - Departement of Electrical Engineering - Research Group on 
Document Architectures
Kasteelpark Arenberg 10 - 3001 Leuven-Heverlee - BELGIUM
tel: +32 16 32 85 51
http://www.docarch.be/ 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

Received on Wednesday, 21 September 2005 17:00:46 UTC