/    Sign up×
Community /Pin to ProfileBookmark

getting vars across frames

i have two frames on my page. one of them is named “forum” and it has an input field named “name” under a form named “form1”. i’m trying to write the value of “name” on the other frame. I tried

[code=php]document.write(parent.frames[“forum”].form1.name.value);[/code]

in the other frame but it didnt work. any suggestions?
Also is there any way to execute a function in frame2 that is located in frame1?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@CharlesMar 25.2005 — [font=monospace] document.write(parent.forum.form1.name.value)[/font]
Copy linkTweet thisAlerts:
@Warren86Mar 25.2005 — "name" is a reserved word. The "name" of the field should be something else.

----------- Frameset ----------------

<HTML>

<frameset rows="80,*" frameborder="yes" border="1" framespacing="0" >

<frame name="forum" scrolling="yes" src="forum.html" >

<frame name="other" scrolling="yes" src="other.html">

</frameset>

</HTML>

----------------- Forum.html --------------

<HTML>

<Body>

<Form name='form1'>

Some name: <input type=text size=10 name='isName'>

</Form>

</Body>

</HTML>

----------- Other.html -----------------

<HTML>

<Head>

<Script Language=JavaScript>

function getName(){

nameTxt = parent.frames.forum.document.forms.form1.isName.value;
document.getElementById('isName').innerHTML = nameTxt;
}


</Script>

</Head>

<Body>

<Div id='isName'></Div>

<input type=button value="Write Name Field Here" onclick="getName()">

</Body>

</HTML>
Copy linkTweet thisAlerts:
@frothauthorMar 26.2005 — hmm... i'm getting a permissions error. is it possible to do this if my "forum" frame's src is remote to the other frame's src?
Copy linkTweet thisAlerts:
@Warren86Mar 26.2005 — No. ALL JavaScript works only with documents that are on the same domain.
×

Success!

Help @froth spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...