D
davidemazza82
Hi all,
I need to set the attributes onload and onresize of the <body> tag
in a HTML file via javascript code.
I want to obtain a programmatic equivalent of the following HTML line:
<body onload="onLoad();" onresize="onResize();">
When I try to inspect the content of the attributes with the following
Javascript code:
var body_elm = document.getElementsByTagName('body').item(0);
document.writeln(body_elm.getAttribute('onload'));
document.writeln(body_elm.getAttribute('onresize'));
I got:
function anonymous() { onLoad(); } function
anonymous() { onResize(); }
But if I substitute the previous <body> tag with one without
arguments:
<body>
and try to set the attribute values programmatically:
var html_doc = document.getElementsByTagName('body').item(0);
html_doc.setAttribute('onload', 'Timeline
nLoad();' );
html_doc.setAttribute('onresize', 'Timeline
nResize();');
then, inspecting the attribute values, I got:
onLoad(); onResize();
How can I obtain the same values for the attributes as in the first
case:
function anonymous() { onLoad(); } function
anonymous() { onResize(); }
by setting them programmatically with the setAttribute(attrname,
attrvalue) method?
Tnx, Davide
I need to set the attributes onload and onresize of the <body> tag
in a HTML file via javascript code.
I want to obtain a programmatic equivalent of the following HTML line:
<body onload="onLoad();" onresize="onResize();">
When I try to inspect the content of the attributes with the following
Javascript code:
var body_elm = document.getElementsByTagName('body').item(0);
document.writeln(body_elm.getAttribute('onload'));
document.writeln(body_elm.getAttribute('onresize'));
I got:
function anonymous() { onLoad(); } function
anonymous() { onResize(); }
But if I substitute the previous <body> tag with one without
arguments:
<body>
and try to set the attribute values programmatically:
var html_doc = document.getElementsByTagName('body').item(0);
html_doc.setAttribute('onload', 'Timeline
html_doc.setAttribute('onresize', 'Timeline
then, inspecting the attribute values, I got:
onLoad(); onResize();
How can I obtain the same values for the attributes as in the first
case:
function anonymous() { onLoad(); } function
anonymous() { onResize(); }
by setting them programmatically with the setAttribute(attrname,
attrvalue) method?
Tnx, Davide