Click to See Complete Forum and Search --> : cannot get html by using document.innerHTML


druss
12-17-2003, 10:25 PM
i am getting no errors from the javascript however i still cannot use the html that is extracted by using then document.innerHTML method.

i have a page that decrypts a javascript encryption that i am using, so far i am able to decrypt and even write the output in another fram however i cannot get the html source code in an iframe one the same page as the decryption script. the page in the ifram is not a third party page.

so far this is where i think its going wrong:


var counter = document.frames['test'].document.innerHTML;
function decryptform() {
encryptedsource = decrypt(counter, "`", "78")


it works fine when on the page in the 'test' iframe has the following content


<script>window.top.decryptform('9834756383479')</script>


however then the main script page must be changed to the following:


function decryptform(counter) {
encryptedsource = decrypt(counter, "`", "78")


could someone please tell me where i am going wrong while trying to get the html from the page in the 'test' iframe and put it in the variable counter.

also the html in the iframe is a single line.

i am sorry that i cannot post the actual whole script but it is far too large.

Thanks
Goran

fredmv
12-17-2003, 10:27 PM
Try using document.body.innerHTML instead.

druss
12-17-2003, 10:32 PM
nup, no luck.

i tried changing it to:
document.frames['test'].body.innerHTML;

and to:
document.body.frames['test'].innerHTML;

any other way??

fredmv
12-17-2003, 10:34 PM
document.frames['test'].document.body.innerHTML;

druss
12-17-2003, 10:38 PM
sorry, still nothing.....

could it be that it is getting the code but just not writing it out?? or is there another way??

thanks alot for your help

fredmv
12-17-2003, 10:41 PM
You're welcome. Try this:alert(document.frames['test'].document.body.innerHTML);

druss
12-17-2003, 10:46 PM
hmmm, no alert message comes up at all, nor does an error??


i thought maybe you would need the iframe line i used

<iframe src="test.htm" name="test"></iframe>




ok when i modified it and changed the code to the following i got the alert and it said undefined
<iframe src="test.htm" name="test"></iframe>
<script>alert(document.frames['test'].document.innerHTML);</script>

fredmv
12-17-2003, 10:51 PM
See attachment.

druss
12-17-2003, 10:55 PM
ok, it worked. thanks alot


Goran

fredmv
12-17-2003, 10:59 PM
You're very welcome. :D