473,651 Members | 3,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Flushing out text on a page? (Possibly simple AJAX question)

The title is pretty vague, I couldn't agree on how to word my inquiry
correctly, but I can explain. I'm writing a simple wiki script that is
contained in one HTML file (yes, it's been done before). I'm having
trouble with clearing anything displayed in the current document and
writing new text.
The primitive code (method calls and other needless stuff taken out)
I'm using goes as follows:

function showPage()
{
top.document.op en();
top.document.wr ite("");
top.document.cl ose();
document.write( "New Page");
}

On certain browsers, new text is simply displayed on the screen, all is
well. On Firefox and FF-based browsers, a completely new page is loaded
only containing the text "New Page" as its source. Everything else is
gone, a view source shows that "New Page" is the only contents of the
document. Of course, I need the rest of the code to run this script!

This is probably an exremely dumb question, but I don't know where to
begin looking for a solution. Is there any way that I could only have a
<por <divthat text is dynamically taken and added to? How would I
do this?

Oct 2 '06 #1
3 1634
o.********@gmai l.com wrote:
The title is pretty vague, I couldn't agree on how to word my inquiry
correctly, but I can explain. I'm writing a simple wiki script that is
contained in one HTML file (yes, it's been done before). I'm having
trouble with clearing anything displayed in the current document and
writing new text.
The primitive code (method calls and other needless stuff taken out)
I'm using goes as follows:

function showPage()
{
top.document.op en();
top.document.wr ite("");
top.document.cl ose();
document.write( "New Page");
}

On certain browsers, new text is simply displayed on the screen, all is
well. On Firefox and FF-based browsers, a completely new page is loaded
only containing the text "New Page" as its source. Everything else is
gone, a view source shows that "New Page" is the only contents of the
document. Of course, I need the rest of the code to run this script!

This is probably an exremely dumb question, but I don't know where to
begin looking for a solution. Is there any way that I could only have a
<por <divthat text is dynamically taken and added to? How would I
do this?
Add a div to your document, give it an id. Find the div with
document.getEle mentById() and then either write the contents with
innerHTML or use DOM methods to add and remove text nodes

--
Ian Collins.
Oct 2 '06 #2
Thanks! That's exactly what I needed. Posting some sample code here for
any fellow noobs with the same question:

<script type="text/javascript">
function ()
{
document.getEle mentById('text' ).innerHTML="<h 1>Text has been
changed.</h1>"
}
</script>
<div id="text" onClick="nameou t()">
Click on this text.
</div>
Ian Collins wrote:
o.********@gmai l.com wrote:
The title is pretty vague, I couldn't agree on how to word my inquiry
correctly, but I can explain. I'm writing a simple wiki script that is
contained in one HTML file (yes, it's been done before). I'm having
trouble with clearing anything displayed in the current document and
writing new text.
The primitive code (method calls and other needless stuff taken out)
I'm using goes as follows:

function showPage()
{
top.document.op en();
top.document.wr ite("");
top.document.cl ose();
document.write( "New Page");
}

On certain browsers, new text is simply displayed on the screen, all is
well. On Firefox and FF-based browsers, a completely new page is loaded
only containing the text "New Page" as its source. Everything else is
gone, a view source shows that "New Page" is the only contents of the
document. Of course, I need the rest of the code to run this script!

This is probably an exremely dumb question, but I don't know where to
begin looking for a solution. Is there any way that I could only have a
<por <divthat text is dynamically taken and added to? How would I
do this?
Add a div to your document, give it an id. Find the div with
document.getEle mentById() and then either write the contents with
innerHTML or use DOM methods to add and remove text nodes

--
Ian Collins.
Oct 2 '06 #3
That won't always work... there are certain circumstances when
innerHTML is readonly. Look into DOM methods.

o.********@gmai l.com wrote:
Thanks! That's exactly what I needed. Posting some sample code here for
any fellow noobs with the same question:

<script type="text/javascript">
function ()
{
document.getEle mentById('text' ).innerHTML="<h 1>Text has been
changed.</h1>"
}
</script>
<div id="text" onClick="nameou t()">
Click on this text.
</div>
Ian Collins wrote:
o.********@gmai l.com wrote:
The title is pretty vague, I couldn't agree on how to word my inquiry
correctly, but I can explain. I'm writing a simple wiki script that is
contained in one HTML file (yes, it's been done before). I'm having
trouble with clearing anything displayed in the current document and
writing new text.
The primitive code (method calls and other needless stuff taken out)
I'm using goes as follows:
>
function showPage()
{
top.document.op en();
top.document.wr ite("");
top.document.cl ose();
document.write( "New Page");
}
>
On certain browsers, new text is simply displayed on the screen, all is
well. On Firefox and FF-based browsers, a completely new page is loaded
only containing the text "New Page" as its source. Everything else is
gone, a view source shows that "New Page" is the only contents of the
document. Of course, I need the rest of the code to run this script!
>
This is probably an exremely dumb question, but I don't know where to
begin looking for a solution. Is there any way that I could only have a
<por <divthat text is dynamically taken and added to? How would I
do this?
>
Add a div to your document, give it an id. Find the div with
document.getEle mentById() and then either write the contents with
innerHTML or use DOM methods to add and remove text nodes

--
Ian Collins.
Oct 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
14557
by: Chamomile | last post by:
does anyone know if its possible to full-justfy text in a <textarea>? I can do left and right justify and center with a simple style declaration, but can't find any reference anywhere to a full justify as can be done in a regular <td> for example.
3
8523
by: Eric | last post by:
Good afternoon, Can anyone help me with flushing the buffer in ASP.NET. I have a set of functions that perform a series of maintainence operations. As these functions are called sequentially, each contains a status as to the success or failure of the particular process. I want to be able to send to the client each output string at it happens. The way it is working right now is that it is storing the output until all of the functions...
5
3476
by: Vincent A. | last post by:
Hello, I'm developping an asp.net application which used master page on which i add several web control. One of the them is a menu control which as several button in order to develop each sub menu. When i click on this button it rises a postback and refresh all my controls. My question is the following : is it possible the postback acts only on one web control ? Thanks in advance
5
2207
by: Martin | last post by:
Hello NG, I've been doing some AJAX for a few weeks now. The basics worked fine so far, but now I've got the following problem which I can't solve: With AJAX you typically update/replace only parts of your page. But in my application there are situation when I first notice on the server -- so AFTER sending an AJAX request -- that I have to update the complete page instead of only some parts. And what do I do now???
9
1900
by: paul | last post by:
Hi All, We have a small dilemma. We have the following page: http://giggsey.com/m00Cow.php (don't ask about the content) that we want to turn into an interactive application for some new intake students at our school. However - we want to have multiple client PCs running a web interface that will allow them to type in their name / a message, and then this message appears on the "scroller" page, which will be on a projector.
5
443
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I change the text in the url/location bar? ----------------------------------------------------------------------- This text can only be altered by changing the URL of the page. The normal solution is to use frames, though this can introduce problems of its own. ===
14
23147
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So, we're looking for a way to display the page with a "please wait..." message while the process is running, and then, when the process is done, update the page with the actual results/page content. We have a page that opens another browser/page...
16
39401
by: dybalabj | last post by:
I realize this should probably be a simple solution, but I have only been learning PHP and MySQL for a couple weeks. I am attempting to write an invoicing system that uses a MySQL database to store invoices, product pricing, and customer contact info. I would like to automatically fill in the customer's contact info after typing in the first and last name, and the product pricing info after typing in the product name. From my searches I've...
2
1696
by: Moiseszaragoza | last post by:
I am not sure if this goes in here ot the ASP forum I have been trying to get some simple AJAX on my site but its not going so well I am not sure what my problems is what i am trying to do is populate a text field Here is my code
0
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8584
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5615
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.