Forum Moderators: open

Message Too Old, No Replies

removeNode("true") firing an incomplete http request

404 error in web server logs due to removeNode("true")

         

skyzhere

10:50 am on Feb 26, 2009 (gmt 0)

10+ Year Member



Hi All,

I have been observing huge number of 404 error messages in the logs of the web server which redirects requests to the application server.

The error message is for the http request to an incomplete URL which is something like [<server-name>...] The resource name for which the request is issued is not present and so it throws a 404 error.

The same error could be observed in a standalone application using tools like HTTPAnalyser and HTTPWatch.

On initial analysis it was found that the http request was fired from one of the functions in the HTC files which does the clean up of the menu items.

On putting some alerts and using the HTTPWatch tool it was observed that the below line of code is the one which fires the HTTP request to a non-existent resource.

Below is the HTTPWatch Log..

+ 2.8400.014392284GET404text/html;charset=ISO-8859-1http://localhost/ContextRoot/ModuleWeb/desktop/

********
if (d.body && d.body.parentElement)
{
d.body.parentElement.removeNode(true);
}
where var d = oMenu.popup.document;
********

Can some one please tell me why do i have a HTTP request fired whenever removeNode() is called? Has any body else seen such behavior before? If yes, then let me know if you found any solution for this.

Cheers

Rambo Tribble

10:02 pm on Feb 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does the target element have any child nodes? removeNode is supposed to leave child nodes intact, which can cause some odd behavior if not carefully controlled.

skyzhere

11:28 am on Mar 2, 2009 (gmt 0)

10+ Year Member



Yes it does have child nodes and that is why i have passed the boolean "true" while calling removeNode() to ensure that the child nodes are also cleared.

coopster

3:16 pm on Mar 2, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Any eventListener running that may be causing the issue?

Rambo Tribble

11:15 pm on Mar 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are there any forms involved? Any idea how this URL is being generated?

[edited by: Rambo_Tribble at 11:16 pm (utc) on Mar. 6, 2009]

skyzhere

12:03 pm on Mar 10, 2009 (gmt 0)

10+ Year Member



All the events are already cleared before the removeNode() is called. Below is the code snippet for the same.

if (oMenu.popup) {
var d = oMenu.popup.document;

if (d) {
d.me = null;
d.onmouseover = "";
d.onmouseout = "";
d.onmouseup = "";
d.onmousewheel = "";
d.onkeydown = "";
d.oncontextmenu = "";
var ss = d.styleSheets;
var l;
if (ss) {
l = ss.length;
// Loop for every style sheet
for (i = 0; i < l; i++)
ss[i].href = "";
}
ss = null;

if (d.body && d.body.parentElement) {
d.body.parentElement.removeNode(true);
}
d.open( "text/html", "replace" );
d.write( "" );
d.close();
}
d = null;
}
oMenu.popup = null;

Rambo,

There is no form involved. It just a HTML menu generated from the XML. I am not sure from where the URL gets generated. Another observation that i had is if I comment out "d.body.parentElement.removeNode(true);" or set the boolean value to 'false' in removeNode(), then i dont get the HTTP request and hence the 404 error.

It looks like while removing the child nodes, the request is fired but i am not able to get the element for which this happens.

Is there any way I can iterate the child nodes of "d.body.parentElemt" and debug the issue? I tried using alerts but it always displays [Object] in the pop up.. Is there any function which gives me the tag name of the element?

Thanks all for your help.

Rambo Tribble

9:53 pm on Mar 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay, but if the node you're removing is the parent element to the body, that's the whole <html></html> shootin' match, not just a menu.

[edited by: Rambo_Tribble at 9:54 pm (utc) on Mar. 11, 2009]