By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,935 Members | 1,512 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,935 IT Pros & Developers. It's quick & easy.

cross frame scripting

P: 7
i have two frames in a frameset. i want pass variables between them i have write the following code.

Expand|Select|Wrap|Line Numbers
  1. <frame set>
  2. <frame src="forte.html" name="frame1">
  3. <frame src="http://192.168.1.6/sample.html" name="frame2">
  4. </frame set>
  5.  
in forte.html file
i wrote the following script
<script language="javascript">
function fun1()
{
window.parent.frame2.form.contact.value=999;
}
</script>
<body>
<form name="form" action="">
<input type="text" name="contact">
</body>
Apr 18 '12 #1
Share this Question
Share on Google+
12 Replies


100+
P: 1,059
what happened after you wrote this code?
Apr 19 '12 #2

P: 7
i'm not able to pass variables between those frames.
is it possible to access dom objects of url address.please help me.
thanks
Apr 19 '12 #3

P: 7
From FRAME A, I'm trying to access the content of FRAME B, which is loaded in from a different server. Is there a way of doing that? Can I assign everything on the page contained in FRAME B to a variable and then examine the contents of this variable?
please help me ?
Apr 19 '12 #4

100+
P: 1,059
try

Expand|Select|Wrap|Line Numbers
  1. parent.window.frame_name.variable_name
  2.  
Apr 19 '12 #5

P: 7
yes i have already tried it is not coming.

2nd frame src is a url another server 192.168.1.4.
the file is present another system.can i modify that file form text field value.
Apr 19 '12 #6

100+
P: 1,059
try ifram, i tested with ifram, it works fine
Apr 19 '12 #7

P: 7
can u give example for that please
Apr 19 '12 #8

100+
P: 1,059
This code works fine for me
index.php
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
  2.    "http://www.w3.org/TR/html4/frameset.dtd">
  3. <HTML>
  4. <HEAD>
  5. <TITLE>A simple frameset document</TITLE>
  6. </HEAD>
  7. <FRAMESET cols="20%, 80%">
  8.  
  9.       <FRAME name='j1' src="johny.htm">
  10.       <FRAME name='j2' src="johny_2.htm">
  11. </FRAMESET>
  12. </HTML>
  13.  
johny.htm
Expand|Select|Wrap|Line Numbers
  1. <INPUT TYPE=BUTTON onclick="alert(parent.window.j2.test_var);" value='haha'>
johny_2.htm
Expand|Select|Wrap|Line Numbers
  1. johny
  2. <SCRIPT>
  3. var test_var='my name is johny';
  4. </SCRIPT>
It works fine in chrome
Apr 19 '12 #9

P: 7
that's ok thanks but in mycase 2nd frame src is url like http://192.168.1.6/sample.html.
Expand|Select|Wrap|Line Numbers
  1. <form name="f1">
  2. <input type="text" name="contact"></form>
  3.  
i want assign that text box.
javascript function not working for that because 2nd frame src not local.it stored in another computer.so i want access external dom file
Apr 19 '12 #10

100+
P: 1,059
I made another test, it works in my machien too

johny.htm
Expand|Select|Wrap|Line Numbers
  1. <INPUT TYPE=BUTTON onclick="alert(parent.window.j2.kaka.value);" value='haha'>
  2.  
johny_2.htm
Expand|Select|Wrap|Line Numbers
  1. johny
  2. <SCRIPT>
  3. var test_var='my name is johny';
  4. </SCRIPT>
  5.  
  6. <input type='text' value='test' id='kaka'>
make it work for you too
Apr 19 '12 #11

100+
P: 1,059
it was not suppose to be a problem. cause browser don't recall remote or local. for browser all are remote
Apr 19 '12 #12

P: 7
thank you i will try that
Apr 19 '12 #13

Post your reply

Sign in to post your reply or Sign up for a free account.