comp.lang._java_script__ FAQ - Quick Answers- 9.91 - 2008-01-19 1 _meta_-FAQ _meta_-questions 2 comp.lang._java_script__ tips 2.1 Which newsgroups deal with _java_script__? 2.2 What questions are off-topic for clj? 2.3 What do I have to do before posting to clj? 2.4 Why was my post not answered? 2.5 How do I direct someone to this FAQ? 2.6 What is ECMA_script_? 2.7 What is J_script_? 2.8 What are _object_ models? 2.9 What is the document _object_ model? 2.10 Internationalization and Multinationalization in _java_script__. 2.11 I have a question that is not answered in here or in any of the resources mentioned here but I'm sure it has been answered in clj. Where are the clj archives located? 2.12 What does the future hold for ECMA_script_? 3 _java_script__ resources 3.1 What books cover _java_script__? 3.2 What online resources are available? 4 Quick Answers 4.1 How do I protect my _java_script__ code? 4.2 How can I disable the back button in a web browser? 4.3 How can I access the client-side filesystem? 4.4 How can I see in _java_script__ if a web browser accepts cookies? 4.5 How can I prevent access to a web page by using _java_script__? 4.6 How do I convert a Number into a String with exactly 2 decimal places? 4.7 Why does simple decimal arithmetic give strange results? 4.8 How do I communicate between _frame_s in a web browser? 4.9 How do I find the size of the window/browser canvas area? 4.10 How do I check to see if a childwindow is open, before opening another? 4.11 Why does _frame_name.print() not print the correct _frame_ in IE? 4.12 Why does K = parseInt('09') set K to 0? 4.13 How do I get the value of a form control? 4.14 How do I close a window and why does it not work on the first one? 4.15 How do I modify the current page in a browser? 4.16 How do I trim whitespace - trim/trimRight/trimLeft 4.17 How do I force a reload from the server/prevent caching? 4.18 How do I get a perl/asp/php variable into client-side js? 4.19 Why do I get permission denied when accessing a _frame_/window? 4.20 How do I make a 10 second delay? 4.21 Why does 1+1 equal 11? or How do I convert a string to a number? 4.22 How do I generate a random integer from 1 to N? 4.23 How do I change print settings with window.print()? 4.24 I have <a href= _java_script__

omefunction() what ... ? 4.25 My element is named myselect[] , how do I access it? 4.26 How do I detect Opera/Netscape/IE? 4.27 How do I disable the right mouse button? 4.28 How do I change the confirm box to say yes/no or default to cancel? 4.29 How do I log-out a user when they leave my site? 4.30 How do I format the Last-Modified date with _java_script__? 4.31 Why are my rollovers so slow? 4.32 How do I change the text in the url/location bar? 4.33 How do I prompt a Save As dialog for an accepted mime type? 4.34 How do I run a server side _script_? 4.35 I have window.status= Moomin ; why doesn't the statusbar change? 4.36 How do I modify the current browser window? 4.37 How do I POST a form to a new window? 4.38 How do I download a page to a variable? 4.39 How do I access a property of an _object_ using a string? 4.40 When should I use eval? 4.41 Why doesn't the global variable divId always refer to the element with id= divId ? 4.42 How do I open a new window with _java_script__? 4.43 How do I get my browser to report _java_script__ errors? 4.44 What is AJAX? 4.45 Why is my AJAX page not updated properly when using an HTTP GET request in Internet Explorer? 5 Comments and Suggestions 5.1 Why do some posts have <FAQENTRY in them ? 5.2 How do I make a suggestion? 1 _meta_-FAQ _meta_-questions You are reading the _comp.lang._java_script___ _meta_-FAQ, version 9.91. It is available on the web at <URL:
http://www.jibbering.com/faq/index.html in HTML form. This is the official _comp.lang._java_script___ (clj) FAQ. Or, more accurately, the _meta_-FAQ. It mainly provides URLs to further information about _java_script__, and some hints and tips to make your stay in comp.lang._java_script__ more enjoyable. This document was created for three reasons: to help reduce the high levels of noise on clj, to provide a resource for people new to _java_script__, and to point to locations that contain valuable _java_script__ resources. Each day, one section of the FAQ is posted for review and questions, and as a reminder that the FAQ is available. To cope with a desire for additional explanation and detail relating to some aspects of the FAQ, an additional resource is available at:- <URL:
http://www.jibbering.com/faq/faq_notes/faq_notes.html It has been provided separately to avoid increasing the size of the FAQ to a point where it would be unreasonable to post it to the group. 2 comp.lang._java_script__ tips see <URL:
http://jibbering.com/faq/#FAQ2 Or Wednesdays FAQ posting. 3 _java_script__ resources see <URL:
http://jibbering.com/faq/#FAQ3 Or Wednesdays FAQ posting. 4 Quick Answers 4.1 How do I protect my _java_script__ code? With clientside _java_script__ you can't as your code is distributed in source form and is easily readable. With J_script_, there is the _script_ Encoder (see MSDN), but this is nothing more than obfuscation. Disabling the right mouse button also does nothing to protect your _script_ in a Web browser. Your code is likely protected under copyright laws. See: <URL:
http://www.wipo.int/about-ip/en/copyright.html <URL:
http://webdesign.about.com/od/copyright/Copyright_Issues_on_the_Web_I... 4.2 How can I disable the back button in a web browser? You can't. The browser's history cannot be modified. However, you can use location.replace(url); in some browsers to replace the current page in the history. <URL:
http://msdn2.microsoft.com/en-us/library/ms536712.aspx <URL:
http://docs.sun.com/source/816-6408-10/location.htm#1194240 4.3 How can I access the client-side filesystem? Security means that by default you can't. In a more restricted environment, there are options. For example, using LiveConnect to connect to Java with Netscape, and using the FileSystem_object_ in IE. Check <URL:
http://groups.google.com/group/comp.lang._java_script__/topics for previous posts on the subject. <URL:
http://msdn2.microsoft.com/en-us/library/z9ty6h50.aspx <URL:
http://www.javaworld.com/javaworld/jw-10-1998/jw-10-apptowin32.html 4.4 How can I see in _java_script__ if a web browser accepts cookies? Writing a cookie, reading it back and checking if it's the same. <URL:
http://www.w3schools.com/js/js_cookies.asp Additional Notes: <URL:
http://www.jibbering.com/faq/faq_notes/cookies.html <URL:
http://www.ietf.org/rfc/rfc2965.txt <URL:
http://www.galasoft-lb.ch/my_java_script__/consulting/2001012701/ <URL:
http://www.cookiecentral.com/ 4.5 How can I prevent access to a web page by using _java_script__? In practice you can't. While you could create a suitable encryption system with a password in the page, the level of support you need to do this means it's always simpler to do it server-side. Anything that protects a page other than the current one is definitely flawed. 4.6 How do I convert a Number into a String with exactly 2 decimal places? When formatting money for example, to format 6.57634 to 6.58, 6.5 to 6.50, and 6 to 6.00? Rounding of x.xx5 is uncertain, as such numbers are not represented exactly. See section 4.7 for Rounding issues. N = Math.round(N*100)/100 only converts N to a Number of value close to a multiple of 0.01; but document.write(N) does not give trailing zeroes. ECMA_script_ Ed. 3.0 (J_script_ 5.5 [but buggy] and _java_script__ 1.5) introduced N.toFixed, the main problem with this is the bugs in J_script_s implementation. Most implementations fail with certain numbers, for example 0.07. The following works successfully for M0, N0: function Stretch(Q, L, c) { var S = Q if (c.length0) while (S.length<L) { S = c+S } return S } function StrU(X, M, N) { // X=0.0 var T, S=new String(Math.round(X*Number( 1e +N))) if (S.search && S.search(/D/)!=-1) { return ''+X } with (new String(Stretch(S, M+N, '0'))) return substring(0, T=(length-N)) + '.' + substring(T) } function Sign(X) { return X0 ? + : X<0 ? - : } function StrS(X, M, N) { return Sign(X)+StrU(Math.abs(X), M, N) } Number.prototype.toFixed = function(n){ return StrS(this,1,n) }; <URL:
http://www.merlyn.demon.co.uk/js-round.htm <URL:
http://msdn2.microsoft.com/en-us/library/sstyff0z.aspx 4.7 Why does simple decimal arithmetic give strange results? For example, 5*1.015 does not give exactly 5.075 and 0.06+0.01 does not give exactly 0.07 in _java_script__. _java_script__ numbers are represented in binary as IEEE-754 (IEC 559) Doubles, with a resolution of 53 bits, giving an accuracy of 15-16 decimal digits; integers up to about 9e15 are precise, but few decimal fractions are. Given this, arithmetic is as exact as possible, but no more. Operations on integers are exact if the true result and all intermediates are integers within that range. In particular, non-integer results should not normally be compared for equality; and non-integer computed results commonly need rounding; see 4.6. <URL:
http://msdn2.microsoft.com/en-us/library/7wkd9z69.aspx <URL:
http://www.merlyn.demon.co.uk/js-misc0.htm#DW4 Otherwise, use Math.round on the results of _expression_s which should be of integer value. 4.8 How do I communicate between _frame_s in a web browser? To reference another _frame_, you simply need to step through the _frame_ hierarchy: parent is the page the _frame_ is defined in, parent._frame_name is another _frame_ in the same _frame_set. To access a variable called Moomin in a _frame_ called Snork you would use parent.Snork.Moomin. To call the function Snufkin in that _frame_ you would use parent.Snork.Snufkin(). 4.9 How do I find the size of the window/browser canvas area? While it is often asked about window size, what is more relevant is the canvas area of the browser. Where supported in NN: (NN4.0) var winWidth = window.innerWidth; var winHeight = window.innerHeight; Where supported in IE: (IE4.0) var winWidth = document.body.clientWidth; var winHeight = document.body.clientHeight; Where supported in modern browsers: var winWidth = document.documentElement.clientWidth; var winHeight = document.documentElement.clientHeight; Where supported in DOM compliant browsers: var winWidth, winHeight, d=document; if (typeof window.innerWidth!='undefined') { winWidth = window.innerWidth; winHeight = window.innerHeight; } else { if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!==0) { winWidth = d.documentElement.clientWidth; winHeight = d.documentElement.clientHeight; } else { if (d.body && typeof d.body.clientWidth!='undefined') { winWidth = d.body.clientWidth; winHeight = d.body.clientHeight; } } } Note: The dimensions can not be determined accurately until after the document has finished loading. <URL:
http://msdn2.microsoft.com/en-us/library/ms533566.aspx <URL:
http://docs.sun.com/source/816-6408-10/window.htm#1202446 <URL:
http://msdn2.microsoft.com/en-us/library/ms533024.aspx 4.10 How do I check to see if a childwindow is open, before opening another? var myWin=null; function openWin(aURL) { if (!myWin || myWin.closed ) { myWin=window.open(aURL,'myWin'); } else{ myWin.location=aURL; myWin.focus(); } } <URL:
http://msdn2.microsoft.com/en-us/library/ms533574.aspx <URL:
http://docs.sun.com/source/816-6408-10/window.htm#1201877 4.11 Why does _frame_name.print() not print the correct _frame_ in IE? IE prints the _frame_ that has focus when you call the print method _frame_ref.focus();_frame_ref.print(); <URL:
http://msdn2.microsoft.com/en-us/library/ms976105.aspx 4.12 Why does K = parseInt('09') set K to 0? The parseInt function decides what _base_ to convert a number represented as a string to by looking at the string. It assumes that any string beginning with '0x' or '0X' represents a hexadecimal number, but it has a choice with a leading zero: the string could represent a number that can be either octal or decimal. Assuming octal, the string '09' will be converted to 0 (octal digits are 0-7); assuming decimal, '09' will be converted to 9 (the leading zero is ignored). To force use of a particular _base_, use the radix parameter: parseInt( 09 ,_base_) <URL:
http://msdn2.microsoft.com/en-us/library/x53yedee.aspx <URL:
http://docs.sun.com/source/816-6408-10/toplev.htm#1064173 <URL:
http://www.jibbering.com/faq/faq_notes/faq_notes.html#FAQN4_12 4.13 How do I get the value of a form control? In HTML documents, named forms may be referred to as named properties of the document.forms collection, and named form controls may be referred to as named properties of the form's elements collection: var frm = document.forms[ formname ]; var contrl = frm.elements[ elementname ]; The (string) value property of such controls can be read directly from the element:- var value = contrl.value; var value = (+contrl.value); //string to number: see 4.21 Some exceptions would be: First Exception: Where the control is a SELECT element, and support for older browsers, such as NN4, is required: var value = contrl.options[contrl.selectedIndex].value; Second Exception: Where several controls share the same name, such as radio buttons. These are made available as collections and require additional handling. For more information, see:- <URL:
http://www.jibbering.com/faq/faq_notes/form_access.html Third Exception: File Inputs where most current browsers do not allow the reading of type= file input elements in a way that is useful. 4.14 How do I close a window and why does it not work on the first one? Use windowRef.close(), where windowRef is a window _object_ reference, such as window, top, parent, self, or a reference obtained from the window.open() method. You can only close windows opened by _script_s, no others. <URL:
http://msdn2.microsoft.com/en-us/library/ms536367.aspx <URL:
http://docs.sun.com/source/816-6408-10/window.htm#1201822 <URL:
http://developer.mozilla.org/en/docs/DOM:window.open#FAQ 4.15 How do I modify the current page in a browser? Using the DOM the non-standard but widely implemented innerHTML extension, the following would be sufficient to modify the content of any element that can have content: <div id= anID Some Content</div with _script_ of document.getElementById( anID ).innerHTML= Some <emnew</em Content ; Where anID is the (unique on the HTML page) ID attribute value of the element to modify. The _script_ below adds support for document.all capable browsers. Support for NN4 is also possible, but certain issues mean that it is not listed here. Using the example above, the call would be written: DynWrite('anID', Some <emnew</em Content ) With the below code also in the page: DocDom = (document.getElementById?true:false); DocAll = (document.all?true:false); DocStr='' if (DocAll) DocStr= return document.all[id] if (DocDom) DocStr= return document.getElementById(id) GetRef=new Function( id , DocStr) if (DocStr=='') { DynWrite=new Function( return false ) } else { DynWrite=new Function( id , S , GetRef(id).innerHTML=S; return true ) } An alternative DynWrite function: <URL:
http://www.jibbering.com/faq/faq_notes/alt_dynwrite.html <URL:
http://msdn2.microsoft.com/en-us/library/ms533897.aspx <URL:
http://developer.mozilla.org/en/docs/DOM:element.innerHTML 4.16 How do I trim whitespace - trim/trimRight/trimLeft Using Regular _expression_s (_java_script__ 1.2/J_script_ 3+) : String.prototype.trimLeft = function() { return this.replace(/^s+/,''); } String.prototype.trimRight = function() { return this.replace(/s+$/,''); } String.prototype.trim = function() { return this.replace(/^s+|s+$/g,''); } <URL:
http://docs.sun.com/source/816-6408-10/regexp.htm <URL:
http://msdn2.microsoft.com/en-us/library/6wzad2b2.aspx <URL:
http://en.wikipedia.org/wiki/Regular__expression_ <URL:
http://www.informatics.sussex.ac.uk/courses/it/tutorials/ns_java_script__... <URL:
http://www.merlyn.demon.co.uk/js-valid.htm 4.17 How do I force a reload from the server/prevent caching? To reload a page, use location.reload(). However, this depends upon the cache headers that your server sends. To change this, you need to alter the server configuration. A quick fix on the client is to change the page URI so that it contains a unique element, such as the current time. For example: location.replace(location.href+'?d='+new Date().valueOf()) If the location.href already contains a Query String, use: location.replace(location.href+'&d='+new Date().valueOf()) <URL:
http://www.mnot.net/cache_docs/ <URL:
http://docs.sun.com/source/816-6408-10/date.htm 4.18 How do I get a perl/asp/php variable into client-side js? Use the server-side language to generate the _java_script__: var jsvar= <%= aspvar % ; var jsvar= <?php echo $phpvar ? ; 4.19 Why do I get permission denied when accessing a _frame_/window? In the normal browser security model, it is impossible for a _script_ from one domain to access the properties of pages served from another domain, or a different protocol. Any attempt to access a property in such cases will result in a Permission Denied error. Signed _script_s or trusted ActiveX _object_s can overcome this in limited situations. <URL:
http://msdn2.microsoft.com/en-us/library/ms533028.aspx 4.20 How do I make a 10 second delay? There is no built-in way to pause execution in _java_script__ such as a sleep function, but hosts usually provide a method of some form. Web browsers are designed for event driven programming and only provide the setTimeout and setInterval functions to facilitate timed delays. The delay before calling Snork may exceed the second parameter to setTimeout and setInterval due to implementation differences among browsers. To call the function Snork(), approx 10 seconds after the function Moomin(), you would do this: Moomin() setTimeout('Snork()',10000) _script_ execution is not stopped, and adding Snufkin() after the setTimeout line would immediately execute the function Snufkin() before Snork() Achieving delays through running a loop of some sort for a pre-defined period is a bad strategy, as that will tend to put CPU use up to 100% and inhibit whatever was supposed to be happening during the delay. Other (less event driven) hosts have different wait functions, such as W_script_.Sleep() in the Windows _script_ Host. <URL:
http://msdn2.microsoft.com/en-us/library/ms536753.aspx <URL:
http://docs.sun.com/source/816-6408-10/window.htm#1203758 <URL:
http://en.wikipedia.org/wiki/Event-driven_programming 4.21 Why does 1+1 equal 11? or How do I convert a string to a number? _java_script__ variables are loosely typed: the conversion between a string and a number happens automatically. Since plus (+) is also used as in string concatenation, '1' + 1 is equal to '11': the String deciding what + does. To overcome this, first convert the string to a number. For example: +varname or Number(varname) or parseInt(varname, 10) or parseFloat(varname). Prompt and form control values are strings, as is the result from a prompt window. Convert these to numbers before performing addition. Additional Notes: <URL:
http://www.jibbering.com/faq/faq_notes/type_convert.html <URL:
http://msdn2.microsoft.com/en-us/library/67defydd.aspx 4.22 How do I generate a random integer from 1 to N? Method Math.random() returns a value R such that 0 <= R < 1.0 ; therefore function Random(x) { return Math.floor(x*Math.random()) } gives an evenly distributed random integer in the range from 0 to x-1 inclusive; use Random(N)+1 for 1 to N. <URL:
http://msdn2.microsoft.com/en-us/library/41336409.aspx <URL:
http://docs.sun.com/source/816-6408-10/math.htm How to Deal and Shuffle, see in: <URL:
http://www.merlyn.demon.co.uk/js-randm.htm 4.23 How do I change print settings with window.print()? In a normal security environment, you can't change anything. The page _style_sheet rules provide some options, but are not supported in browsers yet. If you can, use an ActiveX or Plugin _script_X and Neptune from Meadroid to give you more control for Windows versions of Internet Explorer, Netscape, and Opera. <URL:
http://www.meadroid.com/_script_x/ <URL:
http://msdn2.microsoft.com/en-us/library/ms976105.aspx 4.24 I have <a href= _java_script__

omefunction() what ... ? Whatever the rest of your question, this is generally a very bad use of the _java_script__ pseudo protocol. It was designed so that a function could return a new document. For example: _java_script__: <pHello</p . Using it simply to call a function when a _link_ is clicked causes an error in user agents that do not support _java_script__, or have _java_script__ disabled. Instead, use <a href= something.html _onclick_= somefunction();return false where something.html is a meaningful alternative. Alternatively, place the _onclick_ event on another element so that users without _java_script__ aren't even aware that it does anything. <URL:
http://www.useit.com/alertbox/20021223.html 4.25 My element is named myselect[] , how do I access it? Form controls with any illegal characters can be accessed with formref.elements[ myselect[] ] - The bracket characters, amongst others, are illegal in ID attributes and _java_script__ identifiers, so you should try to avoid them as browsers may handle them incorrectly. <URL:
http://msdn2.microsoft.com/en-us/library/ms537449.aspx <URL:
http://docs.sun.com/source/816-6408-10/form.htm <URL:
http://www.jibbering.com/faq/faq_notes/faq_notes.html#FAQN4_25 4.26 How do I detect Opera/Netscape/IE? The navigator _object_ contains strings which specify the browser and version; however, this is in general not very genuine. Mozilla (and therefore Netscape 6+) allows this to be freely set, and Opera and IE allow it to be modified. There are also at least 25 other _java_script__ capable browsers with their own strings here. Generally though, you don't need to identify which browser is being used. There are alternative techniques, but which one you choose depends on why you want to redirect browsers. If it's to offer different CSS _style_sheets, then <URL:
http://w3development.de/css/hide_css_from_browsers/ shows many techniques. For _script_ing, __object__ detection is a better method to use. <URL:
http://www.quirksmode.org/js/support.html It is also known as feature detection. _object_/feature detection means checking that the _object_ you wish to use is supported by the browser before using it. This means that you don't need to know what browsers support what methods, and your code will automatically be usable on any browser that can execute it. if (document.getElementById && document.getElementById('el') && document.getElementById('el')._style_ ) { // We know that this browser supports getElementByID and has // a _style_ _object_, so we can set a _style_ property. document.getElementById('el')._style_.color= red ; } Browser bugs can often be detected and overcome in similar ways. <URL:
http://developer.mozilla.org/en/docs/Using_Web_Standards_in_your_Web_... <URL:
http://www.jibbering.com/faq/faq_notes/not_browser_detect.html <URL:
http://developer.apple.com/internet/webcontent/_object_detection.html 4.27 How do I disable the right mouse button? The _oncontextmenu_ intrinsic event is the only safe and reliable method. Of the other approaches often presented, most depend on an alert box interrupting the process and rarely work. Note that _oncontextmenu_ is a non-standard event and is not supported on all browsers. <body _oncontextmenu_= return false 4.28 How do I change the confirm box to say yes/no or default to cancel? The buttons on a confirm box cannot be changed, nor can you specify a default button. However, you should be able to change the question so that OK is suitable as the default. e.g. change We will now buy ourselves a Porsche with your credit card, Do you want to continue with this transaction _OK_ Cancel to We will now buy ourselves a Porsche with your credit card, Would you like to abandon this transaction? _OK_ Cancel 4.29 How do I log-out a user when they leave my site? This cannot be done reliably. Here's why: The user may disable _java_script__ so the log-out _script_ will never execute. The user may not be on-line when they close your web page. _java_script__ errors elsewhere in the page may prevent the _script_ executing. The browser may not support the _onunload_ event, or may not fire it under certain circumstances, so the log-out function will not execute. The URL below has more information. <URL:
http://groups.google.com/groups?selm=BlmZ7.55691%244x4.7344316%40news... 4.30 How do I format the Last-Modified date with _java_script__? Apparently, new Date() reads it correctly, though problems can occur if the browser returns only two digits for the year. In particular, time zone, field order and separators may vary. It is also reliant on the server's clock having been correctly set at the time of upload. See the URL below. <URL:
http://www.merlyn.demon.co.uk/js-date2.htm#lM 4.31 Why are my rollovers so slow? Images are cached by the browser depending on the headers sent by the server. If the server does not send sufficient information for the browser to decide the image is cacheable, the browser will check if the image has been updated every time you change the src of an image (in some user settings). To overcome this you must send suitable headers. <URL:
http://www.mnot.net/cache_docs/ 4.32 How do I change the text in the url/location bar? This text can only be altered by changing the URL of the page. 4.33 How do I prompt a Save As dialog for an accepted mime type? It is not possible with client-side _java_script__. Some browsers accept the Content-Disposition header, but this must be added by the server. Taking the form:- Content-Disposition: attachment; filename=filename.ext <URL:
http://classicasp.aspfaq.com/general/how-do-i-prompt-a-save-as-dialog... <URL:
http://support.microsoft.com/kb/q260519/ 4.34 How do I run a server side _script_? You trigger a server-side _script_ by setting any _object_'s URL. For example a _frame_, window, or an Image. An image will also swallow the data sent back by the server, so that they will not be visible anywhere. var dummyImage = new Image();dummyImage.src = _script_URL.asp?param= + varName; Mozilla (NN6.2+, Firefox, Ice Weasle etc), Opera 7.6+, Safari1.2+, the Windows version of IE versions 5+, and some other browsers provide the _xml_ HTTP Request _object_. This allows _java_script__ to send HTTP requests directly to the server, and interact with the responses returned. <URL:
http://jibbering.com/2002/4/httprequest.html 4.35 I have window.status= Moomin ; why doesn't the statusbar change? When changing the status in an event (e.g. _onmouseover_) you should return true from the event. Also a number of browsers require a short delay before setting the status to overcome their default behaviour with the statusbar. onevent= setTimeout('window.status='Moomin'',15); Most browsers are configured, by default, to disallow _script_s from setting the status bar text. 4.36 How do I modify the current browser window? In a default security environment you are very limited in how much you can modify the current browser window. You can use window.resizeTo or window.moveTo to resize or move a window respectively, but that is it. Normally you can only suggest chrome changes in a window.open <URL:
http://msdn2.microsoft.com/en-us/library/ms536651.aspx <URL:
http://developer.mozilla.org/en/docs/DOM:window.open 4.37 How do I POST a form to a new window? You use the target attribute on the form, opening a window with that name and your feature string in the _onsubmit_ handler of the FORM. <form ... action= ... target= wndname _onsubmit_= window.open('',this.target,'features');return true; <URL:
http://www.htmlhelp.com/reference/html40/forms/form.html 4.38 How do I download a page to a variable? Within a web-page use the _xml_ HTTP Request _object_, see: <URL:
http://jibbering.com/2002/4/httprequest.html <URL:
http://www.ajaxtoolbox.com/ 4.39 How do I access a property of an _object_ using a string? There are two ways to access properties: the dot notation and the square bracket notation. What you are looking for is the square bracket notation in which the dot, and the identifier to its right, are replaced with a set of square brackets containing a string. The value of the string matches the identifier. For example:- //dot notation var bodyElement = document.body; //square bracket notation, using an _expression_ var bodyElement = document[ bo + dy ]; <URL:
http://www.jibbering.com/faq/faq_notes/square_brackets.html 4.40 When should I use eval? The eval() function should _only_ be used when it is necessary to evaluate a string supplied or composed at run-time; the string can be anything from a simple (but unpredictable) _expression_ such as 12*2.54 to a substantial piece of _java_script__ code. 4.41 Why doesn't the global variable divId always refer to the element with id= divId ? Microsoft introduced a shortcut that can be used to reference elements which include an ID attribute where the ID becomes a global variable. Some browsers reproduce this behaviours but some, most notably Gecko-_base_d browsers (Netscape and Mozilla), do not. The best approach is the document.getElementById method, which is part of the W3C DOM standard and implemented in modern browsers (including IE from version 5.0). So an element with id= foo can be referenced with:- var el = document.getElementById( foo ); <URL:
http://developer.mozilla.org/en/docs/Using_Web_Standards_in_your_Web_... <URL:
http://www.jibbering.com/faq/faq_notes/faq_notes.html#FAQN4_41 4.42 How do I open a new window with _java_script__? New windows can be opened on browsers that support the window.open function and are not subject to the action of any pop-up blocking mechanism with code such as:- if(window.open){ wRef = window.open(
http://example.com/page.html , windowName ); } <URL:
http://developer.mozilla.org/en/docs/DOM:window.open <URL:
http://www.infimum.dk/HTML/JSwindows.html 4.43 How do I get my browser to report _java_script__ errors? Various browsers include mechanisms for reporting _java_script__ errors in more or less detail but often they need to be enabled or actively viewed. The quick way of activating error messages in the Windows version of IE is to wait until a little yellow triangle appears at the left end of the status bar, double click on it and, when the error dialog box appears, check the Always show errors checkbox it contains. It is also possible to enable/disable error reporting from the Internet Options dialog available through the menus. Mac IE error reporting is enabled through the preferences dialog. Netscape, Mozilla and other Gecko-_base_d browsers have a _java_script__ console that displays errors. It can be viewed by typing _java_script__: into the address bar, and it is sometimes also available as a menu item. There is also a Firebug extension for Mozilla _base_d browsers: <URL:
http://www.getfirebug.com/ Opera's _java_script__ console can be opened from the Tools menu (Tools Advanced _java_script__ console). Alternatively, you can have it open automatically by selecting the Open _java_script__ console on error checkbox in the _java_script__ preferences Section. Unreviewed is a developer Console for Opera: <URL:
http://dev.opera.com/articles/view/opera-developer-tools/?page=2 For Safari see: <URL:
http://developer.apple.com/internet/safari/faq.html#anchor14 4.44 What is AJAX? AJAX is shorthand for Asynchronous _java_script__ And _xml_. The technology is _base_d on the _xml_HttpRequest _object_. It is also known as Web 2.0 . At its simplest, it is the sending/retrieving of new data from the server without changing URL's or reloading the current page. Mozilla Documentation: <URL:
http://developer.mozilla.org/en/docs/_xml_HttpRequest MSDN Documention: <URL:
http://msdn2.microsoft.com/en-us/library/ms535874.aspx <URL:
http://msdn2.microsoft.com/en-us/library/ms759148.aspx AJAX Libraries and Tutorial Sites: <URL:
http://jibbering.com/2002/4/httprequest.html <URL:
http://www.ajaxtoolbox.com/ An alternative to the _xml_HttpRequest _object_ is Remote _script_ing: <URL:
http://www.ashleyit.com/rs/main.htm 4.45 Why is my AJAX page not updated properly when using an HTTP GET request in Internet Explorer? Microsoft Internet Explorer caches the results of HTTP GET requests. To ensure that the document is retrieved from the server, you will need to use the POST Method. <URL:
http://msdn2.microsoft.com/en-us/library/ms536648.aspx 5 Comments and Suggestions 5.1 Why do some posts have <FAQENTRY in them ? If a poster feels that the question they are answering should be covered in the FAQ, placing <FAQENTRY in your post lets the FAQ robot collect the messages for easy review and inclusion. A Draft Proposal for the FAQ is requested and appreciated. The <FAQENTRY should not be used in posts except in conjunction with a suggestion/proposal for the FAQ. It should also not be literally quoted in replies, instead it should be partly obscured as, e.g. <FAQ**TRY or similar. 5.2 How do I make a suggestion? To make a suggestion to the FAQ, use either the FAQENTRY method above, or email Randy Webb (
This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
) (current FAQ editor) or Jim Ley (
This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
). All comments, suggestions, and especially corrections are welcome. Any email sent to
This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
that does not contain FAQENTRY in the subject line is summarily deleted by my spam filter.