Solved

use javascript to set <iframe> src?

Posted on 2007-04-02
3
2,817 Views
Last Modified: 2012-05-05
Hi,

I need help on writing a javascript fucntion to set the link (src) for the iframe.

Right now, javascript is located at <head>.....here is the javascript code</head>,

and the iframe is somewhere in the HTML page. Thanks.
0
Comment
Question by:yarock
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 17

Expert Comment

by:gops1
ID: 18838233

if this is your IFRAME

<iframe id="test"></iframe>

then your javascript should be:

document.getElementById('test').src='a.html';
0
 
LVL 11

Expert Comment

by:flipz
ID: 18838785
If you have problems with the src attribute, try using:

document.getElementById("fraName").location.href='test.html';
0
 
LVL 6

Accepted Solution

by:
ije earned 500 total points
ID: 18840234
or

document.frames['frameName'].location.href = 'http://www.google.com';

or

document.frames[0].location.href = 'http://www.google.com';
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Glitching Slide Show 19 40
Geolocation works...sometimes 2 40
How to count the number of table cells with a custom attribute and class? 7 39
Error just appeared 3 23
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question