Jump to content
  • Advertisement
Sign in to follow this  

[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.

If you intended to correct an error in the post then please contact us.

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:
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 this post

Link to post
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 this post

Link to post
Share on other sites
Source code? Well here's a stripped-down version.
<html><head><title>Test IFRAME</title></head>
<script type="text/javascript">
function doIt(){
<iframe id="my_if" width="300" height="300"
<br /><input id="my_in" type="text" value="Test Me" /><button type="button"

and view.xhtml is
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="style.css" />
<title>IFRAME content</title>

<body style="background: white">
<p>Initial content</p>

Share this post

Link to post
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){

And in the parent window have

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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!