Closed Thread Icon

Topic awaiting preservation: getElementById Issues (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=27134" title="Pages that link to Topic awaiting preservation: getElementById Issues (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: getElementById Issues <span class="small">(Page 1 of 1)</span>\

 
protoculture
Nervous Wreck (II) Inmate

From:
Insane since: Oct 2003

posted posted 12-12-2005 17:46

I'm haivng a problem with using getElementById....

I have a main page that contains an IFRAME pointing to two src documents...

call them

doc 1 and doc 2

Now, doc 1 calls a javascript function in doc 2 ( which has a document.getElementById ) function. The function gets called, but when the point is reached to refer to an object in doc2 ( via the document.getElementById ), I get an object not found error?

Why is this?

Here is my function code....

function showObjects(daString){


// This below did not work so I tried the other one...
document.getElementById("numberlayer").innerHTML = daString;


// This does not work either...
parent.frames['navFrameSetup'].document.getElementById("numberlayer").innerHTML = daString;



}

(Edited by protoculture on 12-12-2005 17:49)

DocOzone
Maniac (V) Lord Mad Scientist
Sovereign of all the lands Ozone and just beyond that little green line over there...

From: Cardiff By The Sea, California
Insane since: Mar 1994

posted posted 12-12-2005 17:53

It's hard to say without actual examples, but I've been burned repeatedly over the years in situations like this by built-in security features of most browsers. Basicalll, any time I try going up the tree, and then down into another iframe in order to call a javascript function, it has the potential to trigger errors. Rather than to find out exactly what is wrong here, have you considered simply putting *all* of the javascript in the top page? the iframes below should have no trouble refering to a top.function(), and the top.functions should have not trouble refering down to the contained iframes. I do this all the time now when dealing with iframes, it works, and it keeps things neater, too!

Your pal, -doc-

protoculture
Nervous Wreck (II) Inmate

From:
Insane since: Oct 2003

posted posted 12-12-2005 17:55

Nevermind me guys... it was some server side code causing the problem.

cheers

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

posted posted 12-12-2005 18:02

Doc: Glad to see you in the halls.

protoculture: are the 2 documents on the same domain ? If not, then you're doomed. Cross server scripting, XSS in short, is disabled for obvious security reasons. Otherwise, you should try to see where exactly your

code:
parent.frames['navFrameSetup'].document.getElementById("numberlayer").innerHTML

statement crash. Ok you can't retrieve the innerHTML property, what about the getElementById("numberlayer") ? Still don't work ? go one step before, and so on.

Oh, and you should try to use a Dom inspector to find the object in your documents.


[edit] Aaaaaarr. I wrote that for nothing [/edit]



(Edited by poi on 12-12-2005 18:03)

protoculture
Nervous Wreck (II) Inmate

From:
Insane since: Oct 2003

posted posted 12-12-2005 18:26

lol, thanks for the tip... but it wasn't for nothinhg.

where can I get this 'dom inspector' ?

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

posted posted 12-12-2005 19:08

In FireFox, it's in Tools > DOM Inspector, provided you've installed the web.dev tools when you installed FireFox.

In Opera, there is no proper DOM Inspector but Christian Krebs did some bookmarklets for that

In IE, it's in the developer toolbar. You can download on MS's website.


Hope that helps,



(Edited by poi on 12-12-2005 19:09)

BillyRayPreachersSon
Bipolar (III) Inmate

From: London
Insane since: Jul 2004

posted posted 12-13-2005 11:40

Poi,

I had no idea about that toolbar - it's bloody good, all things considered - some really nice time-saving tools there. Thanks for the details!

Dan

whisperstorm
Nervous Wreck (II) Inmate

From: California
Insane since: Jul 2004

posted posted 12-13-2005 16:35

There is also a killer suite of favelets/bookmarklets from Steve at Slayeroffice.com :

http://slayeroffice.com/?c=/content/tools/suite.html

I particularly like the "mouseover dom inspector".

--- RPG Fan ---

« BackwardsOnwards »

Show Forum Drop Down Menu