Hi

I want to change a webpage in javaScript, but in a special way. I want to 
run a a javascript on a HTML-file and save the result into a new HTML-file. 
for example:

HTML-file:
--------------------------
<html>
.
.
.
<body>
<div id="id1" style="position: absolute; top:452px; left:78px; width:80px; 
height:80px;">this is div no 1</div>
<div id="id2" style="position: absolute; top:4px; left:712px; width:80px; 
height:80px;">this is div no 2</div>
.
.
.
</body></html>
--------------------------

js-file/SCRIPT FILE
--------------------------
var id1 = document.getElementById('id1');
id1.style.left = '0';
id1.style.top  = '0';
--------------------------


I want the result to be... HTML-result
--------------------------
<html>
.
.
.
<body>
<div id="id1" style="position: absolute; top:0px; left:0px; width:80px; 
height:80px;">this is div no 1</div>
<div id="id2" style="position: absolute; top:4px; left:712px; width:80px; 
height:80px;">this is div no 2</div>
.
.
.
</body></html>
--------------------------
The coordinates in the div 1 has changed.

(Is this possible at all?)
I want to do this in java that's why I tried rhino.



Java code
--------------------------
.
.
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("JavaScript");
.
.
engine.put("htmlfile", f); 
//f is a HTML-file
engine.eval("var span = htmlfile.getElementById('span');");     //A test row 
of javaScript
f = (File)engine.get("file"); 
//The result.. (which in this case should be exactly the same as the 
HTML-file)
.
.
--------------------------
However I get a exception:
Exception in thread "main" javax.script.ScriptException: 
sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot find 
function getElementById. (<Unknown source>#1) in <Unknown source> at line 
number 1

"Cannot find function getElementById"?

am I dong something wrong or isn't getElementById implemented yet? (is this 
possible to do in this way?)

Michael 


_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to