Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Re:Iframe(sorry, should have posted in last thread)

Status
Not open for further replies.

silentq

Programmer
Sep 17, 2007
16
CA
Sorry to post again in a new thread, the other one was marked as resolved so I figured nobody would look at it.

I wanted to make another function that moves the text from the master(parent) page into the iframe.
Here is the code again.(moveText) is the function that I cant figure out.
Code:
<body>

<style type="text/css">
#div1 { color:red }
#div2 { color:blue }
#div3 { color:green }
</style>

<div id="div1">
This is word one
</div>

  <iframe name=myiframe src=iframe2.php width=300 height=300 frameborder=1 scrolling=no></iframe>
   
   <script language="javascript">
   
   function newText() {
   document.getElementById('div1').innerHTML=myiframe.document.getElementById('div2').innerHTML;
   }
   
   function moveText() {
	window.parent.getElementById(...?
   }
   
   
  </script>
  <form>
  <input type="button" value="New Text" onclick="newText()" />
  </form>
  <p>
   <form>
  <input type="button" value="Move Text" onclick="moveText()" />
  </form>
  
  

</body>
 
You mean like this?
Code:
function moveText()
{
myiframe.document.getElementById('div2').innerHTML = document.getElementById('div1').innerHTML;
}

That function would be in the top frame/page and move the text from there into the page in the iframe.

Lee
 
Yes thats it. Now could I use this if I made another iframe and then move words from one to another?(changing the values in the parenthesis)?
 
You know, if you did some experimentation you'd find the answers a lot more quickly than asking some of your questions here.

And I still recommend that you find some good online Javascript tutorials.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top