|
The purpose of this webpage is to describe a method for writing JavaScript in WebTV PageBuilder webpages. Writing JavaScript in PageBuilder webpages is frustrating with many problems, because of the way our PageBuilder program works – it's basically an HTML table "template" program that uses individal "text" and other content "entry" boxes and options to assemble the various parts of the document into a complete webpage document on the WebTV webpage servers. Many PageBuilders have successfully written and used online C&P scripts in their webpages. This webpage describes "workaround" procedures PageBuilders are using to overcome the limitations of PageBuilder scripting. Here's the major problem illustrated by the code for a simple alert written the way we typically see it written in the text books and C&B script source websites. But, this will not work in PageBuilder webpages, because of the comment tags and added <br> tags. See those <br> tags in the script below? Those break tags were added by PageBuilder when I used the space and return keys to space the script out, to add "whitespace" to make it look like the "easy to read" book scripts. In fact, except for the added break tags, this script looks just like the scripts you see in books. <script language="javascript"> <br> If it wasn't for the way the PageBuilder editor handles our attempts to space out script for easy reading, It would work? WebTV PageBuilder is a "table" template webpage editor. The various objects, text, images, lists, links, etc, in the body tag are placed within table data cells (<td>'s). The <script> tag is legal within table data cell tags! But, the above script will not work in PageBuilder webpages. The biggest problem is that you cannot space out your scripts for easy reading and use HTML comments to explain your script! PageBuilder puts <br> tags in your scripts when you try to space the code with a "return" key, or long extra spaces, which kills your scripts. And you cannot use comment tags inside your scripts in a PageBuilder webpage to hide from old browsers, or label each section with explanatory comments. The <br> tags in the above script were added when I put returns to space out the code on separate lines. I also tried using the space bar to cause the code to auto-wrap and appear on separate lines for easy reading; but for some reason, a <br> tag was entered after the first line, and the last line and space before the last line was "sucked" back up to the third line. It's real quirky; sometimes PageBuilder puts in a break tag, and sometimes it just "sucks back" extra spaces? You just cannot type good looking code with WebTV, unless you follow the procedure suggested here. The above alert script works fine when I type it into GeoCities Advanced Editor, because it doesn't have the break tags added by the editor. Also, other webpage editors allow HTML comment tags (<!-- comments here // ->) to label and explain various parts of the scripts, and to hide the scripts from non-javascript browsers. But, PageBuilder doesn't work with comment tags inside the scripts! The PageBuilder program is a "table" template on our wbpage servers, that uses javascript to manipulate (paste-in) all the text boxes, images, links, lists, etc. into the basic table template on the webservers for our webpages. In the PageBuilder editor, the javascript is used only to put together the various parts of our webpage document, not to read and execute our scripts. The PageBuilder program javascript assumes it's working with an HTML document in table format. Therefore; when we use comment tags in our scripts, they are assumed to be HTML comments, and all script code between the comment tags is embed in the PageBuilder document, but is hidden from execution by the comment tags. You must write your scripts without comment tags to allow them to be properly embeded in your webpage document, to be read and executed by the javascript interpreters in our WebTV client boxes. Many C&P scripts PageBuilders are using are C&P'd from free online webpages and seem to contradict the above rules; but, those webpage script sources use advanced editors that do not put the destructive returns (<br> tags) noted above in the script codes. You can C&P many online scripts because they are made with script editors – just be sure you don't use any comments, or add any extra spaces or returns, which cause a <br> or broken statements code. In fact, I recommend that you always remove all comments that enclose script code; and remove extra spaces from all the scripts you use. You can use comment tags before or after the <script> ... </script> tag to enclose the script author's credits and other info; but, just don't ever put your scripts inside comment tags in a PageBuilder document! WebTV supports only the <script language="javascript"> attribute, and does not support the type="text/javascript" attribute. But, you need to put it in for other browsers. The language attribute is depreciated in HTML 4, and not recognized in 5.0 browsers. You should only use the script tag with language and type attributes once in a heading at the beginning of your document. Use "Add a heading" in PageBuilder Basic Editor; but, if you use PageBuilder Advanced Editor, you will have to code an <h3> or <h2> heading in the large "Add text" box after your new body tag – the Advanced Editor comment tags block out the headings ahead of the large text box that you use your ending comment tag in. You should only put the script tag with language and type attributes once in the heading at the top of a PageBuilder document. After that you can use simple <script> .. your scripts here .. </script> tags and type all your scripts close together anywhere else in the body of your document. Your scripts must be spaced with single spaces between variables, functions, and statements. Write your variables in a continous line with semicolons and single spaces, using the "var" keyword; ie, var a=5; var b=10; etc. Write functions with single spaces and closely spaced curley brackets ({}) around your statements. Use the correct statement syntax and allow your lines of script to auto-wrap – no returns inside your scripts between the opening and closing script tags! Here's an example of the way you must always write your scripts in a PageBuilder document: See how the above script is closely spaced. You must always type your PageBuilder scripts like that. You must always allow long script statements to auto-wrap. Use the space bar only, for the required single spaces. Remember: no returns or extra spaces! Note: When using PageBuilder Advanced Editor, any "heading" text boxes ahead of the large "Add text" box, where you enter your ending comment tag, are blocked out by the comment tags, because the ending comment tag is placed in the large "Add text" box ahead of the new body tag; and also remember: the title for the text box you enter your AE ending comment tag in is also blocked out. You must put your ending comment tag and new body tag in an "Add text" box at the top of your editor screen. You can use event handler alerts, such as onLoad, onUnoad, in this new body tag; but, no function calls, because you haven't defined your functions yet. Then you just "Add a heading" text box below the new body tag text box to define your functions for use in your document. Also, remember: If you create a PageBuilder multi-page Advanced Editor document, you must have a separate new body tag text box and heading text box for your scripts at the top of each individual page! You should always view the source code of your PB AE webpages to see how the comment tags block out parts of the webpage template, and check for any needed HTML element opening or closing tags that you will need to add to properly close unused PB table template tags. Don't leave "single" HTML tags caused by your AE comment tags – always add back any missing (blocked out) HTML element tags to properly "pair" and close unused paragraph and table template tags. This is a test to see if a simple javascript alert inside <script> tags will work in PageBuilder. The simple "alert" you saw when you accessed this webpage follows this paragraph. The script code without comment tags and language attribute is shown in the paragraph below.Here's the code for the simple alert: I have used this simple script syntax many times and verified that it works in PageBuilder websites, anywhere in the document; as it does being placed inline down here towards the bottom of this webpage.This simple script syntax seems to work fine with webtv and computer browsers, and will apparently workaround PageBuilder javascript problems. I have not encountered any problems using the "type" and "language" attributes in a script tag with script variables and function statements in a PageBuilder "Heading" and then just using the simple <script> tag anywhere else in the PageBuilder document. The semi-colon before the closing </script> tag is optional, but is usually used to end statements, so I use it here. That simple script shows how you have to closely type your scripts. Now, in summary, remember: all we have to do to make javascript work in a PageBuilder document is use this simple script syntax to write script function statements between these simple script tags. It can be done OK, by just typing the function scripts without comments, closely spaced, one-space maximum, between variables, functions and statement "braces" with auto-wrapped lines. You can't use a "return" to space out and indent lines, enter comments, or all the other editing functions you normally use with other webpage editors to make scripts easy to read and understand. Note: the script shown above causes the alert to appear when it comes in focus in the document window, which occurs while the document body is loading; which is why the alert occured before the body text was loaded into the page. It's a demo only of the simple way javascript code must be written for use in PageBuilder webpages. It would be more practical to put this alert in a body, image or link tag with an event handler.Please note: I DO NOT RECOMMEND THAT YOU USE ANY "ADDED" <HTML> TAGS preceeding any of your PageBuilder webpage scripts! It is not necessary, yet many PageBuilders suggest you do so. This practice, using added <HTML> tags, has come into widespread use among WebTV PageBuilders because of the use of C&P'd free online scripts that contain "Returns" for "whitespace" that allow scripts to be easily read by authors and users. When you use scripts with "Returns" in a PageBuilder text box, you add these spaces in your document – which also occurs if you use "Returns" to space out HTML code, such as long table codes that you would like to space out for clarity. When PageBuilders do add an extra <HTML> tag before scripts in a text box, it works because our PageBuilder software program just considers that to be a separate Basic Editor document that is added into the PageBuilder basic webpage table "template" on the webpage servers. But, this added illegal <HTML> tag, which works with PageBuilder websites on our WebTV browsers, will not work on computer browsers! Write your scripts as I have here – USE SINGLE SPACES WHERE REQUIRED BETWEEN YOUR FUNCTION VARIABLES AND STATEMENTS, AND ALLOW YOUR TEXT BOX SCRIPTS TO AUTO-WRAP – NO "RETURNS" OR EXTRA SPACES IN YOUR PAGEBUILDER "SCRIPT" TEXT BOXES! If you C&P scripts, just remove all extra spaces so you will not have to add the extra <HTML> tag to make the script work! Also, another problem with WebTV PageBuilder webpage scripting is the fact that there seems to be a misunderstanding about the difference between the PageBuilder <head> tag and the PageBuilder "Add a heading" text boxes. PageBuilder headings are not the same as the built-in HTML <head> tag. PageBuilder "headings" are <h2>....</h2> tags for a level 2 heading that uses size "6" bold fonts, and which are placed in the <body> of the document. The HTML <head> tag is a document head block; immediately following the opening <html> tag, and preceeding the document <body> or <frameset> tag, which defines information about the document and includes the following HTML information tags: <meta>, <title>, <base>, <link>, <script>, and <style>. If you want to load scripts with the "onLoad" event handler in the body tag, you must have these scripts defined in the head tag of the document, before the body tag content loads. Use the PageBuilder Advanced Editor procedure to block the built-in head tag, so you can extend the head tag to an "Add text" box for all your scripts that must be loaded before being "called" in the body of the document. However, with WebTV PageBuilder, you can C&P scripts, complex tables, and other HTML code that contains comment tags and extra "whitespace" created by "Return(s)" if you do use a beginning <HTML> tag, as many PageBuilders are currently doing because of the way our PageBuilder program works, as explained above; but, it won't work on other browsers. I wrote other PageBuilder javascript demo pages describing blinking status bars, scrolling status bar messages, and blinking marquees that shows the script syntax suggested here. Check them out at: http://community-2.webtv.net/jaxred/BlnkStat/ The blinking and scrolling status bar message demos shows that you can easily write complex javascipt in PageBuilder documents if you follow this simple scripting syntax I suggest here. I have seen lots of PageBuilder webpages with cut-and-paste javascript. There's a wide diversity in PageBuilder scripting methods, because of the way the PageBuilder table "template" program works, subject to different opinions; and, many of the scripting methods work fine with WebTV, but will not work on computers. I make these suggestions here as another alternative for PageBuilder scripting |
|
JaxRed
|
|
|
| |
|
|
||
|
|
||
|
|
||