Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
changing contents of remote frame problem
Old 02-25-2008, 01:50 AM changing contents of remote frame problem
Sharon_leic's Avatar
Super Talker

Posts: 115
Name: Sharon
Location: Leicester, uk
Trades: 0
Hiya!

I have a main page

main.html
in it are

<iframe name='types' src='types.php' height='500' width='190' frameborder='0' scrolling='yes'></iframe>

<iframe name='bets' src='bets.php' height='500' width='190' frameborder='0' scrolling='yes'></iframe>

what i need to do is target 1 frame from another.

i know i can do it with a link like this,
<a href='bets.php' target='bets' >Refresh</a>

but lol

it need to do it in a function so it don't have to be clicked on..

basically, every time name='types' gets refreshed, it auto refreshes name='bets' at the same time.

Thanks for any help if you can give me a solution.

Shaz x
__________________
mysql_connect("localhost", "brain", "sharon") or die(mysql_error());
mysql error: brain doesn't exist!
Sharon_leic is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-25-2008, 08:06 AM Re: changing contents of remote frame problem
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
you cannot using pure html, as far as I know.
But with javascript, it's possible.
Code:
//from 1 iframe
top.name_of_iframe.location="new_url";
You can define a function with 2 parameters for that, and call it from the href:
Code:
<script type="text/javascript">
function goTo(href,iframe){
  if(top.iframe){
    top.iframe.location=href;
  }
}
</script>

<a href="javascript:goTo('1.html','bets');">a link</a>
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-25-2008, 10:42 AM Re: changing contents of remote frame problem
Sharon_leic's Avatar
Super Talker

Posts: 115
Name: Sharon
Location: Leicester, uk
Trades: 0
Hiya

its got to be done auto from a function not by link.

what it is, some info is submitted by 1 iframe and it updates the other automatically but cant have the parent that houses both the frames refresh...

a good example is in phpMyAdmin, when you add a new field in the right hand frame and it updates the left hand but don't update the parent.

I have tried a few examples from the web but even if i give the iframes a name, the script returns "object not found"

thanks for any help!

Shaz x
__________________
mysql_connect("localhost", "brain", "sharon") or die(mysql_error());
mysql error: brain doesn't exist!
Sharon_leic is offline
Reply With Quote
View Public Profile
 
Old 02-25-2008, 10:54 AM Re: changing contents of remote frame problem
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Simply remove the part that is in the "href" in my example, and call it directly then.
it will have the same effect.
Or directly use the "top.framename.location=" call, it will work.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-25-2008, 11:14 AM Re: changing contents of remote frame problem
Sharon_leic's Avatar
Super Talker

Posts: 115
Name: Sharon
Location: Leicester, uk
Trades: 0
It won't work

It works if the code is in the parent frame and i am using the link or function to change an iframe thats inside it.. but not if i use it in 1 iframe to change another as it can't find the window i am trying to change

I know in 1 iframe i can use this

<a href='bets.php' target='bets' >Refresh</a>

and it will change the contents in the other iframe

just wish i could use the 'target=' bit in javascript as it would work then
__________________
mysql_connect("localhost", "brain", "sharon") or die(mysql_error());
mysql error: brain doesn't exist!
Sharon_leic is offline
Reply With Quote
View Public Profile
 
Old 02-25-2008, 11:29 AM Re: changing contents of remote frame problem
Sharon_leic's Avatar
Super Talker

Posts: 115
Name: Sharon
Location: Leicester, uk
Trades: 0
Here is an image of what i am trying to do lol



it all works fine apart from the refresh.. and yeah its ugly at the moment as not finished lol

they place a bet on the left side, the bet gets processed then the black section( named placed bets ) needs to refresh to show the bet.

both the left side bit that takes the bets and the black part are both in iframes.
__________________
mysql_connect("localhost", "brain", "sharon") or die(mysql_error());
mysql error: brain doesn't exist!
Sharon_leic is offline
Reply With Quote
View Public Profile
 
Old 02-25-2008, 11:50 AM Re: changing contents of remote frame problem
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
yes it will.
The key is the "top." before the command.
This keyword tells the browser to get the root window, the parent of any frame that is relative to the current page.

So, in your configuration, the frame that send the command,by prefixing the top. before the iframe name, will make the browser start from the frameset.
http://www.irt.org/script/18.htm
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-25-2008, 11:56 AM Re: changing contents of remote frame problem
Sharon_leic's Avatar
Super Talker

Posts: 115
Name: Sharon
Location: Leicester, uk
Trades: 0
ok i got it now thanks

It wasn't working because the actual iframe it is in, isn't the top iframe

i have all in an ifram that is in another iframe so it couldn't find it lol

sorted it now thanks

Shaz x
__________________
mysql_connect("localhost", "brain", "sharon") or die(mysql_error());
mysql error: brain doesn't exist!

Last edited by Sharon_leic; 02-25-2008 at 12:17 PM..
Sharon_leic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to changing contents of remote frame problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27245 seconds with 12 queries