Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 18th, 2005, 01:51 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Alhambra, ca, USA.
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default Easy hyperlink ques with iframe

Hello
I have a menu on the left with hyperlinks. On the right I have a <iframe> where I want to switch to different .htm files as the user clicks on the menu hyperlinks.

I got this to work with image menu items rather than hyperlinks. But I can't get it to work with hyperlinks.

Below code is what I used for image menu items.

<SCRIPT LANGUAGE="JavaScript">
function cFs(NewSource)
{
var oFrame = document.getElementById("fraContent");
oFrame.src = NewSource;
}
</SCRIPT>

<img src="images/x.gif" onclick="cFs('6_p1.html');" name="x">

<iframe id="fraContent" src="somepage.html" ></iframe>


How can I get this to work with <a href> tag??

Thank you.
  #2 (permalink)  
Old September 18th, 2005, 03:52 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well if your <a> has the page to show in the href and the iframe has a name of fraDisplay then pure HTML with no JavaScript is sufficient:
Code:
<a href="6_p1.html" target="fraDisplay">6_p1.html</a>
otherwise you will have to tell us what you need and what you mean when you say that it dosn't work.

--

Joe (Microsoft MVP - XML)
  #3 (permalink)  
Old September 18th, 2005, 12:11 PM
Friend of Wrox
 
Join Date: Jun 2004
Location: Alhambra, ca, USA.
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello joefawcett,

I am trying to have the iframe (on the right)load different htm pages according to which left menu hyperlink is clicked. If the user clicks <a href="??">6_p1.html</a> then I want the iframe on the same page load up 6_p1.html. I don't want the hyperlink poping up another window.

I believe this can only be done with Javascript. Thank you.
  #4 (permalink)  
Old September 19th, 2005, 04:47 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Don't believe me then :)

--

Joe (Microsoft MVP - XML)
  #5 (permalink)  
Old September 21st, 2005, 02:45 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii bekim!!
Try this

script>
function cFs(NewSource)
{

  var oFrame
oFrame = document.getElementById("fraContent");
  oFrame.src = NewSource;
}
</script>
<a href="javascript:cFs('a1.html')">Test1</a> <br>
<a href="javascript:cFs('a2.html')">Test2</a><br>
<a href="javascript:cFs('a3.html')">Test3</a><br>



<iframe id="fraContent" src="somepage.html" ></iframe>

Hope this will help you

Cheers :)

vinod


Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy Ques -- Datetime validation for Access bekim Access 2 June 16th, 2005 01:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.