Home arrow JavaScript arrow Page 2 - Roots of Crys`s ACP Document Phase Approach
JAVASCRIPT

Roots of Crys`s ACP Document Phase Approach


In this second part of a twelve-part series on Active Client Pages (ACP), I give you the roots that give rise to my approach. One way to learn is by asking questions. We shall use that learning method here. Some of the questions are: can you reference a previously opened page? How can you get and set contents in a page that has just been loaded? When DOM was invented, Active Client Pages technology was not envisioned, so we have to ask these questions.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
July 10, 2009
TABLE OF CONTENTS:
  1. · Roots of Crys`s ACP Document Phase Approach
  2. · How does one open a new document from the current document?
  3. · How do I send HTML contents to a newly opened document?
  4. · Can you access the HTML content of the newly loaded document?

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Roots of Crys`s ACP Document Phase Approach - How does one open a new document from the current document?
(Page 2 of 4 )

The syntax is:


document.open(mimetype,replace)


We saw this syntax in the previous part of the series. The document in the statement above is supposed to refer to the current document. You can type an empty string in place of either of the arguments if you do not need the argument. You can still use the open() method without any parameters.

The default value for the mimetype parameter is "text/html". HTML pages are of this type, so we shall not be using this parameter; we can set it to “” if we have to use the replace parameter. The following code should open a new blank document when you click the button; however, there is a problem with the code, which we shall solve:


<html>

<head>

</head>

<body>

<button type="button" onclick="document.open()">Open New Document from Current Document</button>

</body>

</html>


If you type and save the above code as an HTML file, and then click the button, a new blank document will appear, but the loading process may never end. To solve this problem, follow the statement


document.open()


with


document.close()


as in the following code. Do not forget the semicolon in between the statements in the value of the onclick attribute.


<html>

<head>

</head>

<body>

<button type="button" onclick="document.open();document.close()">Open New Document from Current Document</button>

</body>

</html>


If you try this code, the Back button should be enabled. You should be able to use the Back and Forward buttons. With some browsers the Back and Forward buttons are not really effective under this condition. The reason is probably that until today, you've seen very few ACP activities with browsers; so the designers of these browsers did not emphasize the use of these buttons when documents have to be opened at the client.

Now that ACP has come, browser designers will have to take this seriously. This Back and Forward button problem is not our fault; it is up to these browser designers to make sure that the operation of their Back and Forward buttons is effective. Internet Explorer, Mozilla Firefox and Netscape browsers do not pose any problems in the operation of the Back and Forward buttons in this phase of ACP.

Let me now explain the use of the statement “document.close()”. Before I talk about that, let me remind you of the purpose of the open() method. In the last part of this series, we saw the purpose of this method as (I quote), “Opens a stream to collect the output from any document.write() or document.writeln() methods.” It says that the open method opens a stream; it did not say that the open() method opens a document.

For our purpose, know that when you open a stream, you have to close it, and in that way, you have opened a document. Well, the phrase used for open here is (loaded). So when a document is opened as such, they say the page document is loaded. So the close() method closes the stream, and after that our document is loaded. Write (see below) the document content in between the open and close statements. The document in both statements of the onclick attribute addresses the current document.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 7 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials