JS Error when accessing an element from another frame

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sayid
    New Member
    • Mar 2008
    • 1

    JS Error when accessing an element from another frame

    Hello,

    I have a problem when altering a DIV-element from another frame.
    The frameset looks like this:

    Code:
    <frameset rows=0,0,* border=0>
    		<frame name=header src=/header.htm scrolling=no noresize="true" frameborder=0>
    		<frame name=border src=/border.htm scrolling=no noresize="true" frameborder=0>
    		<frameset cols=200,* border=0>
    			<frameset rows=*,0 border=0>
    				<frame name=bodytree src=/emptytree.asp scrolling=no noresize="true" frameborder=0>
    				<frame name=bodyref src=/ref.asp scrolling=no noresize="true" frameborder=0>
    			</frameset>
    			<frameset rows=*,0 border=0>		
    				<frame name=body src=/login.asp noresize="true" frameborder=0>
    				<frame name=bodycom src=/comm.asp scrolling=no noresize="true" frameborder=0>
    			</frameset>
    		</frameset>
    	</frameset>
    Frame 'ref.asp' (bodyref) is not viewed on the screen and is used to maintain the login session object by refreshing it every 4 minutes using this simple piece of code:

    Code:
    <META HTTP-EQUIV="REFRESH" CONTENT="250; url=/ref.asp">
    Now I want to check (every 4 minutes) in 'ref.asp' if things have changed in my database. If so, then update an element in frame 'bodytree' using this code:

    Code:
    parent.frames["bodytree"].document.getElementById('alerting').innerHTML = '<ul><li>Changed!</li></ul>';
    The element 'alerting' is a simple DIV-element in the bodytree-frame.
    Weirdest thing is that the element is being updated but I get this JS error:

    Code:
    'parent.frames.bodytree.document' is empty or not an object
    When I place the JS-code in a webpage from the body-frame then everything works fine. But when I place it in ref.asp I get the error. Does anyone have an idea why I get the error?

    Thx...
  • rnd me
    Recognized Expert Contributor
    • Jun 2007
    • 427

    #2
    when you call it from ref.asp, it is not in any frame.


    likely using simply document.getEle mentById('alert ing') to find it will work.

    Comment

    Working...