#1
  1. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Posts
    29
    Rep Power
    0

    Cross-frames javascript


    Hi!

    I'm currently working on a content management system. Part of this CMS is an online image library (similar to macromedia). Today, another question.
    My image library is situated in a frame, seperated from the editor (where the edit part is an <iframe> with contenteditable=true). On clicking in de library frame, I want to paste an image in the editor frame. The functions I planned to use are usually embedded in the code of the editor frame:


    PHP Code:
     
    function cmdExec(cmd,opt
        {
         
    idContent.document.execCommand(cmd,"",opt);idContent.focus();
        }

    function 
    PastePlaatje(locatie)
        {
        if(
    locatie!=nullcmdExec("InsertImage",locatie);
        } 
    How can i fix these functions to work cross-frames? Thanks for your help!

    Max

    BTW, for explaining purposes, here the 'names'.

    As specified in index.htm:
    Library frame: name=library
    Editor frame: name=hoofdscherm

    Editor <iframe>: id=idContent
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Dublin
    Posts
    413
    Rep Power
    14
    have you tried the following:

    document.parent.frames["frameName"].document
    document.iframes["frameName"].document (haven't tried iframes but I'd be surprised if it's much different to this...)
    window.frames[].document etc. ?

    The functions might be part of the frame (window) rather than the document (not sure of the top of my head ... try both)

    You can also refer to the frames / iframes by their index number
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2001
    Posts
    765
    Rep Power
    13
    Try:

    parent.hoofdscherm.frames['idContent']

    There are a number of cross-frame scripting issues you may want to brush up on:

    http://www.oreillynet.com/pub/a/java...=7#multwinfram

    In re your earlier query:

    http://www.byte.com/documents/s=1113...806_udell.html

    What's a hoofdscherm? Can I buy one from you?
    Last edited by mrrichardfeder; April 1st, 2002 at 06:53 PM.

IMN logo majestic logo threadwatch logo seochat tools logo