Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to change iFrame src with <script>

34 views
Skip to first unread message

Vlad

unread,
May 14, 2003, 12:12:01 PM5/14/03
to
Hello.

What I need is a way to change src of iFrame with
javascript fuction.

Here is what is have:

<iframe name="ifr_name" src="file_1.htm">
</iframe>

If I call this function:
function getSrc(){

alert(document.admin_tools.src);

}

I get "undefined".

If I call this function:
function getName(){

alert(document.admin_tools.src);

}

I get "admin_tools"

Why?

If I call this function:
unction setSrc(){

document.admin_tools.src="file2.cfm";

}

nothing happens.

Please, help.


Christoph Basedau

unread,
May 14, 2003, 1:21:44 PM5/14/03
to
am 14.05.03 18:12 sprach Vlad dieses:

> Hello.
>
> What I need is a way to change src of iFrame with
> javascript fuction.
>
> Here is what is have:
>
> <iframe name="ifr_name" src="file_1.htm">
> </iframe>
>
> If I call this function:
> function getSrc(){
>
> alert(document.admin_tools.src);

document.all.ifr_name.src
or: document.getElementsByName("ifr_name")[0].src //if the name is unique
or: document.getElementsByTagName("IFRAME")[0].src //for the 1st iframe


mfg
Christoph

Vlad

unread,
May 14, 2003, 1:46:53 PM5/14/03
to
Great, thank you.
>.
>
0 new messages