| View previous topic :: View next topic |
| Author |
Message |
phil karras Senior Member

Joined: 15 Jul 2002 Posts: 1776 Location: MD
|
Posted: Wed Aug 28, 2002 9:07 am Post subject: HINT: On Passing Data |
|
|
To pass data between frames:
Assume in our frame set we have: Left, Center, Right frames.
Then in Center or Right we use: parent.Left.Var01 = 15; to change the value of Var01 in the Left frame.
To Pass data to/from a Pop-up window:
In the pop-up we use: window.opener.Var01 = 15; to change the value of Var01 in the original window.
In the original window we use: var NewWin = window.open(URL, "Child"); and then NewWinVar02 = 15.67; to change a value in the pop-up window.
WARNING The pop-up window MUST be open and ready for data before you issue the NewWin.Var02 = 15.67; line or no data will be passed!
Now, one last topic, to actually use or do something when a piece of data changes we could use a function like this in the <head> section:
| Code: |
var Var01 = 0;
var LastVal = Var01;
function CheckUm() {
if(Var01 != LastVal) {
// Here we do whatever!
alert("Var01 value has changed from "+LastVal+" to "+Var01);
LastVal = Var01;
}
setTimeout("CheckUm();" 500); // check again in 1/2 sec.
}
.
.
.
<body onLoad="CheckUm();">
.
.
.
|
Now in any frame or window where we want to be able to do something when a given value changes we can.
Passing data between secondary related windows:
The only way I know to do this is via a cookie.
Frames and window.opener/child are directly related, a secondary relationship is a window opened from the same site but not by the initial window. All windows opened by the same site & location can access the same cookie. See my other article on Cookies:
http://www.jsworkshop.com/bb/viewtopic.php?t=15 _________________ Phil K
Circle Software Consulting
Test website: http://cs.yrex.com/
Guidelines for Posting: http://www.jsworkshop.com/posting.html
IHBAAA = It Has Been Asked And Answered
KISS: http://www.jsworkshop.com/bb/viewtopic.php?t=508 |
|
| Back to top |
|
 |
phil karras Senior Member

Joined: 15 Jul 2002 Posts: 1776 Location: MD
|
|
| Back to top |
|
 |
anamika New member

Joined: 27 Mar 2003 Posts: 2
|
Posted: Fri Mar 28, 2003 5:22 am Post subject: |
|
|
thx,
was'nt exactly what I wanted, but got the idea. Was looking for a solution like window.showModalDialog(), but it does not works in netscape.
Can you suggest anything else. |
|
| Back to top |
|
 |
phil karras Senior Member

Joined: 15 Jul 2002 Posts: 1776 Location: MD
|
|
| Back to top |
|
 |
sohnee Senior Member

Joined: 17 Jul 2002 Posts: 2077 Location: UK
|
Posted: Thu Apr 17, 2003 9:04 am Post subject: Passing data to an iframe |
|
|
You can also pass data to and from an <iframe>
Firstly, set up your iframes with a name:
| Code: | <iframe src="about:blank" name="iframe1"></iframe>
<iframe src="about:blank" name="iframe2"></iframe>
|
In the main page you simply use the iframe name to call the function, variable or object you want. From an iframe, you can call functions variables and objects in the main page OR another iframe.
This is how you could do all of these things in one example...
save this as 'iframeexample.html'
| Code: | <html>
<head>
<title>iframe example 1.0</title>
<script LANGUAGE="JavaScript" type="text/javascript">
var wot;
function anothertest(){
alert("This alert is from the parent.");
}
</script>
</head>
<body>
<p>Save this bit as 'iframeexample.html'</p>
<p><a href="#" onClick="iframe1.location.href='http://www.odford.co.uk';">Change the location of IFRAME 1</a></p>
<p><a href="#" onClick="iframe2.test();">Launch a function in IFRAME 2</a></p>
<p>
<iframe src="about:blank" name="iframe1" width="600" height="400"></iframe>
</p>
<p>
<iframe src="pagetwo.html" name="iframe2" width="400" height="200"></iframe>
</p>
</body>
</html> |
save this as 'pagetwo.html'
| Code: | <html>
<head>
<title>iframe example 1.0 - Page Two</title>
</head>
<body>
<p>Save this bit as 'pagetwo.html' in the same folder</p>
<p id="one"><a href="#" onClick="parent.iframe1.location.href='http://www.northernline.net';">Change the location of IFRAME 1 from IFRAME 2 via the 'parent' window.</a></p>
<p id="two"><a href="#" onClick="parent.anothertest();">Launch a function in 'Parent'</a></p>
<script LANGUAGE="JavaScript" type="text/javascript">
function test() {
alert('THIS ALERT HAS COME FROM IFRAME 2 - PAGE TWO');
}
</script>
</body>
</html> |
|
|
| Back to top |
|
 |
phil karras Senior Member

Joined: 15 Jul 2002 Posts: 1776 Location: MD
|
|
| Back to top |
|
 |
phil karras Senior Member

Joined: 15 Jul 2002 Posts: 1776 Location: MD
|
Posted: Wed Aug 06, 2003 11:01 am Post subject: Passing Data from one page to another using <form> &am |
|
|
There's is one more passing data topic that should be covered. It is passing data from a form on one page to another page. In this case the form posts the data, it gets placed in the URL and the new page looks at its URL and picks up the data. Once you have the data you can do whatever you want to it, place it into fields of a new form or whatever.
Here is the form in help266.htm:
| Code: |
<form name='test' post='help266.htm'>
Enter your name: <input type='text' name='Name'>
<input type='submit' name=='submit' value='submit'>
</form>
|
And here is one way to pick up the first FieldName, data pair in the second page:
| Code: |
var data = new Array();
var flds = new Array();
// gets just sent data
var tmp = document.location.search;
// remove the ?
data = tmp.split("?");
// get all FieldName=data pairs
data = data[1].split("&");
// split first data pair into field & data
flds = data[0].split("=");
// display fieldName & data
alert(flds[0] + "\n" + flds[1]);
|
I will be placing all this in help266.htm to show how it works and it will be up on my http://cs.yrex.com/ site. _________________ Phil K
Circle Software Consulting
Test website: http://cs.yrex.com/
Guidelines for Posting: http://www.jsworkshop.com/posting.html
IHBAAA = It Has Been Asked And Answered
KISS: http://www.jsworkshop.com/bb/viewtopic.php?t=508 |
|
| Back to top |
|
 |
karson New member

Joined: 16 Apr 2010 Posts: 1 Location: Pakistan
|
Posted: Fri Apr 16, 2010 7:38 am Post subject: Solution pass values iframe to another iframe |
|
|
1 Main.html // this is main page have in 2 iframes
2 leftframe.html // id is leftframe
3 rightframe.html // id is mainframe
==============================================
this code insert into "leftframe.html"
Add button and call hello function
<script language="javascript">
function hello()
{
top.frames["mainframe"].document.body.style.backgroundColor='red';
top.frames["mainframe"].document.getElementById("TITLE").value = 'HaAHAHAHAHAHAH';
}
</script>
=============================================
rightframe.html
please insert textbox the textbox id is "TITLE"
when you click on leftframe button then
right frame have change the value
I hope you have got my point its working very good
if you know about ajax you can play many script without
refresh page
Best Regards
Faisal Ismail A Karim
Pakistan
03332238826 |
|
| Back to top |
|
 |
phil karras Senior Member

Joined: 15 Jul 2002 Posts: 1776 Location: MD
|
|
| Back to top |
|
 |
zeeshan New member

Joined: 28 Nov 2012 Posts: 1
|
Posted: Mon Dec 17, 2012 9:15 pm Post subject: |
|
|
This code insert into "leftframe.html"
Add button and call hello function:
| Quote: | <script language="javascript">
function hello()
{
top.frames["mainframe"].document.body.style.backgroundColor='red';
top.frames["mainframe"].document.getElementById("TITLE").value = 'I Love Pakistan';
}
</script> |
_________________ www.thenutritiontips.com |
|
| Back to top |
|
 |
dean New member

Joined: 02 Feb 2013 Posts: 1
|
Posted: Sat Feb 02, 2013 5:07 am Post subject: Re: HINT: On Passing Data |
|
|
| phil karras wrote: | To pass data between frames:
Assume in our frame set we have: Left, Center, Right frames.
Then in Center or Right we use: parent.Left.Var01 = 15; to change the value of Var01 in the Left frame.
To Pass data to/from a Pop-up window:
In the pop-up we use: window.opener.Var01 = 15; to change the value of Var01 in the original window.
In the original window we use: var NewWin = window.open(URL, "Child"); and then NewWinVar02 = 15.67; to change a value in the pop-up window.
WARNING The pop-up window MUST be open and ready for data before you issue the NewWin.Var02 = 15.67; line or no data will be passed!
Now, one last topic, to actually use or do something when a piece of data changes we could use a function like this in the <head> section:
| Code: |
var Var01 = 0;
var LastVal = Var01;
function CheckUm() {
if(Var01 != LastVal) {
// Here we do whatever!
alert("Var01 value has changed from "+LastVal+" to "+Var01);
LastVal = Var01;
}
setTimeout("CheckUm();" 500); // check again in 1/2 sec.
}
.
.
.
<body onLoad="CheckUm();">
.
.
.
|
Now in any frame or window where we want to be able to do something when a given value changes we can.
Passing data between secondary related windows:
The only way I know to do this is via a cookie.
Frames and window.opener/child are directly related, a secondary relationship is a window opened from the same site but not by the initial window. All windows opened by the same site & location can access the same cookie. See my other article on Cookies:
http://www.jsworkshop.com/bb/viewtopic.php?t=15 |
if you want to design any type of website then PM to me ...with site requirement .so that i can estimate for this . |
|
| Back to top |
|
 |
wowlijetgold New member

Joined: 09 May 2013 Posts: 3 Location: US,New York
|
Posted: Thu May 09, 2013 2:36 am Post subject: |
|
|
Few things are impossible in themselves; and it is often for want of will, rather than of means, that man fails to succeed.
-----------------------------
Buy Guild Wars 2 Gold | Diablo 3 Gold | WOW Gold |
|
| Back to top |
|
 |
dgtyry Member

Joined: 21 May 2013 Posts: 58 Location: China
|
Posted: Tue May 21, 2013 11:23 pm Post subject: One may fall in love with |
|
|
| One may fall in love with aion gold many people during the lifetime. When you finally get your own happiness, you will understand aion gold the previous sadness is kind of treasure, which makes aion gold you better to hold and cherish the people you love. |
|
| Back to top |
|
 |
dgtyry Member

Joined: 21 May 2013 Posts: 58 Location: China
|
|
| Back to top |
|
 |
|