This is frustrating me. Opening IE displays the following code fine.
When I open a new window the code no longer works. All the HTML is
overwritten with the first document.write statement. Tried with window
tried without Please help.
This code pulls XML from a web site then parses it into a dynamically
created table built with javascript. The write table is not working
correctly, other methods work fine. This code also locks up Fire Fox to
where it doesn't stop loading the page.
var req;
var textColor;
var linkColor;
var columns;
var tWidth;
var bgcolor;
function init () {
if (window.XMLHttpRequest)
req = new XMLHttpRequest();
else if (window.ActiveXObject)
req = new ActiveXObject("Microsoft.XMLHTTP");
// req.open("GET", "http://127.0.0.1/patches/AJAX.xml", true);
req.open("GET",
"http://127.0.0.1/patches/affiliate_AJAX.cfm?Affiliate=1&Campaign=10",
true);
//req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
req.onreadystatechange = callback;
req.send(null);
}
function callback() {
if (req.readyState == 4) {
if (req.status == 200) {
// update the HTML DOM based on whether or not message is valid
// alert('valid request' + req.status + req.readyState);
parseMessage();
// writeTable();
writeTable();
return true;
}
}
}
function parseMessage() {
var message = req.responseXML.getElementsByTagName("fontcolor")[0];
textColor = message.childNodes[0].nodeValue;
message = req.responseXML.getElementsByTagName("linkcolor")[0];
linkColor = message.childNodes[0].nodeValue;
message = req.responseXML.getElementsByTagName("tablecols")[0];
columns = message.childNodes[0].nodeValue;
message = req.responseXML.getElementsByTagName("tablewidth")[0];
tWidth = message.childNodes[0].nodeValue;
message = req.responseXML.getElementsByTagName("bgcolor")[0];
bgcolor = message.childNodes[0].nodeValue;
}
function writeTable() {
window.document.writeln('<table border="0" cellspacing="10" width="' +
tWidth + '" bgcolor="#' + bgcolor + '">');
for (i=0; i<columns; i++) {
if ((i % columns) == 0)
window.document.writeln('<tr>');
//body of each slot
window.document.writeln('<td>');
window.document.writeln('test');
window.document.writeln('</td>');
if ((i % columns) == (columns - 1))
window.document.writeln('</tr>'); //end row if column limit is up
}
window.document.writeln('</table>');
}
GryphonsClaw is online now Edit/Delete Message 2 2666
document.write will not suffice.
there is "state" in a document
that means a "write" is now appended
or destroys a window's canvas?
Look up the write method's other properties
e.g.
open
close
...............
Hope that helps.
"Adam" <ad**@atruereview.com> wrote in message
news:42**********@alt.athenanews.com... This is frustrating me. Opening IE displays the following code fine. When I open a new window the code no longer works. All the HTML is overwritten with the first document.write statement. Tried with window tried without Please help.
This code pulls XML from a web site then parses it into a dynamically created table built with javascript. The write table is not working correctly, other methods work fine. This code also locks up Fire Fox to where it doesn't stop loading the page.
var req; var textColor; var linkColor; var columns; var tWidth; var bgcolor;
function init () { if (window.XMLHttpRequest) req = new XMLHttpRequest();
else if (window.ActiveXObject) req = new ActiveXObject("Microsoft.XMLHTTP");
// req.open("GET", "http://127.0.0.1/patches/AJAX.xml", true); req.open("GET", "http://127.0.0.1/patches/affiliate_AJAX.cfm?Affiliate=1&Campaign=10", true);
//req.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); req.onreadystatechange = callback;
req.send(null); }
function callback() { if (req.readyState == 4) { if (req.status == 200) { // update the HTML DOM based on whether or not message is valid // alert('valid request' + req.status + req.readyState); parseMessage();
// writeTable(); writeTable(); return true;
} }
}
function parseMessage() { var message = req.responseXML.getElementsByTagName("fontcolor")[0]; textColor = message.childNodes[0].nodeValue;
message = req.responseXML.getElementsByTagName("linkcolor")[0]; linkColor = message.childNodes[0].nodeValue;
message = req.responseXML.getElementsByTagName("tablecols")[0]; columns = message.childNodes[0].nodeValue;
message = req.responseXML.getElementsByTagName("tablewidth")[0]; tWidth = message.childNodes[0].nodeValue;
message = req.responseXML.getElementsByTagName("bgcolor")[0]; bgcolor = message.childNodes[0].nodeValue;
}
function writeTable() {
window.document.writeln('<table border="0" cellspacing="10" width="' + tWidth + '" bgcolor="#' + bgcolor + '">');
for (i=0; i<columns; i++) {
if ((i % columns) == 0) window.document.writeln('<tr>'); //body of each slot window.document.writeln('<td>'); window.document.writeln('test'); window.document.writeln('</td>');
if ((i % columns) == (columns - 1)) window.document.writeln('</tr>'); //end row if column limit is up
}
window.document.writeln('</table>'); } GryphonsClaw is online now Edit/Delete Message
Also a table is not written directly like other tags.
A table has its own little object model going,
since it does obey layout margins.
better clinch it into a seperator first.
e.g.
<div> ........... </div>
"Adam" <ad**@atruereview.com> wrote in message
news:42**********@alt.athenanews.com... This is frustrating me. Opening IE displays the following code fine. When I open a new window the code no longer works. All the HTML is overwritten with the first document.write statement. Tried with window tried without Please help.
This code pulls XML from a web site then parses it into a dynamically created table built with javascript. The write table is not working correctly, other methods work fine. This code also locks up Fire Fox to where it doesn't stop loading the page.
var req; var textColor; var linkColor; var columns; var tWidth; var bgcolor;
function init () { if (window.XMLHttpRequest) req = new XMLHttpRequest();
else if (window.ActiveXObject) req = new ActiveXObject("Microsoft.XMLHTTP");
// req.open("GET", "http://127.0.0.1/patches/AJAX.xml", true); req.open("GET", "http://127.0.0.1/patches/affiliate_AJAX.cfm?Affiliate=1&Campaign=10", true);
//req.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); req.onreadystatechange = callback;
req.send(null); }
function callback() { if (req.readyState == 4) { if (req.status == 200) { // update the HTML DOM based on whether or not message is valid // alert('valid request' + req.status + req.readyState); parseMessage();
// writeTable(); writeTable(); return true;
} }
}
function parseMessage() { var message = req.responseXML.getElementsByTagName("fontcolor")[0]; textColor = message.childNodes[0].nodeValue;
message = req.responseXML.getElementsByTagName("linkcolor")[0]; linkColor = message.childNodes[0].nodeValue;
message = req.responseXML.getElementsByTagName("tablecols")[0]; columns = message.childNodes[0].nodeValue;
message = req.responseXML.getElementsByTagName("tablewidth")[0]; tWidth = message.childNodes[0].nodeValue;
message = req.responseXML.getElementsByTagName("bgcolor")[0]; bgcolor = message.childNodes[0].nodeValue;
}
function writeTable() {
window.document.writeln('<table border="0" cellspacing="10" width="' + tWidth + '" bgcolor="#' + bgcolor + '">');
for (i=0; i<columns; i++) {
if ((i % columns) == 0) window.document.writeln('<tr>'); //body of each slot window.document.writeln('<td>'); window.document.writeln('test'); window.document.writeln('</td>');
if ((i % columns) == (columns - 1)) window.document.writeln('</tr>'); //end row if column limit is up
}
window.document.writeln('</table>'); } GryphonsClaw is online now Edit/Delete Message This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: SE |
last post by:
Hi all,
Apologies if this has been done before.
I am trying to do some stuff with XMLHttpRequest in mozilla but no dice. I
have finally pared everything down to the minimum to see what is...
|
by: Greg |
last post by:
Hi,
I've designed a bookmark in Ajax / PHP that I will put soon on
sourceforge.net.
But I've got an very tricky bug.
I try it on some computers with Internet Explorer/Windows, Firefox...
|
by: mathewda |
last post by:
Hey, I'm having a problem that I consider kinda weird that is alluding
me at the moment. I've wrote some code that will set up an
XMLHttpRequest, it then makes a call to open and send and sets the...
|
by: libsfan01 |
last post by:
Hi all
Im trying to write a script that pulls data from another page (which is
getting data from a db). The contents displayed on the db handling page
(display.php) gets transferred through...
|
by: Peter Michaux |
last post by:
Hi,
The FAQ correctly says the following:
"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...
|
by: broughcut |
last post by:
Is it possible to fetch a specific div from a source html document
using XMLHttpRequest, rather than fetching the entire file?
I was going to use Ajax on mouseover but keep the normal link...
|
by: geevaa |
last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3
XMLHttpRequest and AJAX for PHP programmers
James Kassemi
Introduction:
Although the concept isn't entirely new, XMLHttpRequest...
|
by: Tarik Monem |
last post by:
OK, I'm pretty sure this cannot work because I'm trying to use JavaScript (client-side) to write to an xml file (which is server-side) using XMLHttpRequest.
Can I use PHP do what I'm trying to do?...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
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...
|
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...
| |