# [web] *!%\$#ing JavaScript!

This topic is 4890 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Sorry to shove this in the lounge, but it's kinda urgent. I have an iframe and was editing its contents via document.getElementById(iframe_id).contentDocument.body.innerHTML This, or something very similar, was working earlier today. I deleted and re-typed the line and now instead of editing the frame, it throws an exception:
Quote:
 Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLElement.innerHTML]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///home/s0347735/Work/RF3k_map/maps/mapScript.js :: scrollTo :: line 279" data: no]
Interestingly, I can READ the innerHTML with no worries. Also, suddenly, frameobject.contentDocument.evaluate(anything) throws a "not enough arguments" exception. I've re-started firefox and examined the DOM and am now shedding tears of blood cos I overwrote the last working version (it was such a small change...). Please help. Make me look stupid if you have to.

##### Share on other sites
document.getElementById(iframe_id).contentDocument.body.innerHTML works fine. The trouble most be somewhere else in your code, try posting it.

##### Share on other sites
Source code? Well here's a stripped-down version.
Quote:
 Test IFRAME

and view.xhtml is
Quote:
 IFRAME content

Initial content

##### Share on other sites
Now this is getting really odd. I changed the xhtml to an equiavlent html and include a function in bigview like this
function test(t){alert(t);}

And in the parent window have
frames["name"].eval("test('Testing...')");

Which worked. I changed alert(t) to document.body.innerHTML=t which again caused an exception

Then I put a width,height:100% div at position 0,0 and tried divobject.innerHTML=t which also crashed, which is odd since the same approach works in other web pages

Here's the really wierd part...

To test I wasn't going mad I added this to just before the </body>
<script type="text/javascript">test("abc")</script>

Not only does that work, but the existing code in the parent window successfuly sets the contents of the div as well!

Somehow it seems a page's contents can only be externally set if the page itself has performed a similar operation. If it's not a bug it's a pretty obscure feature.

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 101
• 11
• ### Forum Statistics

• Total Topics
632974
• Total Posts
3009660
• ### Who's Online (See full list)

There are no registered users currently online

×