SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Hybrid View

  1. #1
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JS from another frame

    How can I let an javascript in an frame work, by clicking the button in another frame?

    like:
    PHP Code:
    <a href="function();" target="main"
    or so?

    thx!
    _o_ OOP _o_

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    parent.Frame_name_goes_here.document.write('written from other frame')

  3. #3
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is that the whole code?
    _o_ OOP _o_

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if the target is main then it should be this

    parent.main.document.write('written from other frame');

  5. #5
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    aha it works thx!
    just how to do this with js functions?
    _o_ OOP _o_

  6. #6
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    function writeINframe(Uframe,txt)
    {
    parent[Uframe]document.write(txt);

    not that hard is it?

  7. #7
    SitePoint Enthusiast
    Join Date
    Jan 2002
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dont think hes writing to the frame, if not you can put the js in the page ur targeting, or exturnal.js. Thiers other ways, but this is the simplest to explain.

  8. #8
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To perform a function in one frame from another you could do it this way:
    <A HREF="javascript:parent.frame_name.function_name()">Click Here</A>

    Or if it is a form button:
    <INPUT TYPE="button" VALUE="Click" onClick="parent.frame_name.function_name()">
    Last edited by requestcode; Apr 26, 2002 at 07:21.

  9. #9
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the html should be lowercase

    <a href="javascript:parent.frame_name.function_name()">Click Here</a>

    :)

  10. #10
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Andrew,
    The HTML can be Upper or Lower as long as it is not mixed. Either way will work.

  11. #11
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its better to lowercase as its more comliant to xhtml


Bookmarks

Posting Permissions

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