Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: onClick problem

  1. #1
    New Coder
    Join Date
    Dec 2004
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onClick problem

    Hi, I have this script

    Code:
    function loadIframe(iframeName, url) {
    frames[iframeName].location.href = url;
    }
    and I want to use it in my link tag <a href=...> so that when someone clicks on it the function will load.

    Can somebody correct the sytax for me please?!
    THANKS!!

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Why not a direct HTML ?

    <a href="foo.html" target="iframe_name"> ?

    Anyway, here's :

    function loadIframe(iframeName, url) {
    top.frames[iframeName].location.href = url;
    }
    ...
    <a href ="#" onclick="loadIframe('iframe_name', 'foo.html');return false">
    ...
    <iframe name="iframe_name" src="blah.html"></iframe>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •