473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

document.write

7
Hi,
I want to use document.write() in stead of innerhtml. But everything is getting cleared, while writing new content.
I am losing registered callbacks on that object like onclick etc.
But I want to preserve the previous things.
Is this possible?
Oct 12 '07 #1
12 1011
dmjpro
2,476 2GB
Hi,
I want to use document.write() in stead of innerhtml. But everything is getting cleared, while writing new content.
I am losing registered callbacks on that object like onclick etc.
But I want to preserve the previous things.
Is this possible?
try...........

Expand|Select|Wrap|Line Numbers
  1. document.write(document.body.innerHTML+"your content goes here");
  2.  
Debasis Jana
Oct 12 '07 #2
jsuser
7
Nope :(
It does not work.
I want to clear previous content, but not the registered onclick functions.
This preserved my prev content, but still I lost onclick.
Oct 12 '07 #3
dmjpro
2,476 2GB
Nope :(
It does not work.
I want to clear previous content, but not the registered onclick functions.
This preserved my prev content, but still I lost onclick.
On which Control you lost Registered "OnClick"?
Post the related code here.
And tell the problem elaborately.

Debasis Jana.
Oct 12 '07 #4
jsuser
7
I have code something like this -

document.onclick = func;
document.ondblclick = func;
document.onkeyup = func;
etc.

Now when I write

document.body.innerHTML = html;

When I click on the component, the 'func' gets called.

But when my code is

document.open();
document.write(html);
document.close();

The 'func' is never called.
Oct 12 '07 #5
dmjpro
2,476 2GB
I have code something like this -

document.onclick = func;
document.ondblclick = func;
document.onkeyup = func;
etc.

Now when I write

document.body.innerHTML = html;

When I click on the component, the 'func' gets called.

But when my code is

document.open();
document.write(html);
document.close();

The 'func' is never called.
Use code tags....

You better to have it....
Expand|Select|Wrap|Line Numbers
  1. window.onclick = func;
  2. window.ondblclick = func;
  3. window.onkeyup = func;
  4.  
Debasis Jana
Oct 12 '07 #6
jsuser
7
This is just extract of the code what I have.
Actually I can not change that to window.onclick.I am not allowed to touch that code.
Whatever I have to handle is while writing the content. :(
Previously I was using innerhtml only, but for some issues I need to change it to document.write
Oct 12 '07 #7
dmjpro
2,476 2GB
This is just extract of the code what I have.
Actually I can not change that to window.onclick.I am not allowed to touch that code.
Whatever I have to handle is while writing the content. :(
Previously I was using innerhtml only, but for some issues I need to change it to document.write
Well let me know ... what do you want to update?
You want to clear the previous Screen but still want to have event registration.
Right?

Debasisi Jana
Oct 12 '07 #8
jsuser
7
Yes.
exactly :)
I just want to replace the content without disturbing anything else.
Oct 12 '07 #9
dmjpro
2,476 2GB
Yes.
exactly :)
I just want to replace the content without disturbing anything else.
have a try this ..............

Expand|Select|Wrap|Line Numbers
  1. var child_s = document.body.childNodes;;
  2. var i=0;
  3. for(;i<child_s.length;){
  4.  document.body.removeChild(child_s[i]);
  5.  child_s = document.body.childNodes;
  6.  i=0;
  7. }
  8. document.body.innerHTML = "your_html_content";
  9.  
Good Luck !

Debasis Jana
Oct 12 '07 #10
jsuser
7
I can not use innerhtml, bcoz innerhtml gives me problems when I have corrupted html. To overcome corrupted html content, I want to use document.write.
Otherwise in case of innerhtml, all my registrations are preserved.

I am losing the registraions when I do document.write
Oct 12 '07 #11
dmjpro
2,476 2GB
I can not use innerhtml, bcoz innerhtml gives me problems when I have corrupted html. To overcome corrupted html content, I want to use document.write.
Otherwise in case of innerhtml, all my registrations are preserved.

I am losing the registraions when I do document.write
Again you can not do registration, after use "document.write".

Debasis Jana
Oct 12 '07 #12
acoder
16,027 Expert Mod 8TB
I can not use innerhtml, bcoz innerhtml gives me problems when I have corrupted html. To overcome corrupted html content, I want to use document.write.
Otherwise in case of innerhtml, all my registrations are preserved.

I am losing the registraions when I do document.write
You cannot use document.write after the page has loaded. If innerHTML is giving you problems because of corrupted HTML, that's a good thing. Fix the corrupted HTML first.
Oct 15 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: techy techno | last post by:
Hii Just wanted to know how can I decorate my texboxes and Listmenu which is called from a JS file using the following code below: document.write("<SELECT NAME='cur2' ONCHANGE='cconv1();'>");...
2
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of...
14
by: Eli | last post by:
I've got a script that I'm trying to debug which uses document.write() to place HTML within a page. In both IE6 and Firefox when I view source, I see only the script itself and not any HTML as...
4
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
2
by: bissatch | last post by:
Hi, I am trying to use JavaScript to write a table column on a web page. The code is as follows: <html> <head> <script> function displaycount() {
11
by: Tony | last post by:
Is it me, or is document.write just about the most abused js function? Maybe, like goto, js would be better without it? Is there any good reason to use it? Because I'm having a hard time seeing...
1
by: anupamaavadutha | last post by:
hi all, iam new to javascript. i have problem calling javascript functions.iam designing a calender page.here is my code. <%@ page...
8
by: Mateusz Viste | last post by:
Hi, I am trying make some multimedia files playable from my website. So far, I am able to generate dynamically a new page containing the right <embed> section. However, when I load my script, it...
1
by: celeroSolutions | last post by:
This code works in my site in IE, but not in FireFox, and I'm stuck as to why! Any ideas? (The image paths are correct, I've tested these.) <script language="javascript" type="text/javascript">...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.