Allow user to access link in a pop up iframe

Discussion in 'Javascript' started by jeet_sen, Mar 23, 2006.

  1. jeet_sen

    jeet_sen Guest

    Hi,
    I have generated a table and have attached a pop up to display at
    onmouseover event of each cell.
    For each cell the pop up will display cell specific detailed data. I
    have generated the pop up using iframe and it is working fine.
    On mouseout event of each cell I have destroyed the created the
    iframe.
    This is working fine.
    But if I try to move the cursor over the iframe, the mouseout event
    is fired and my iframe is vanishing off.
    Can anyone let me know which event i can attach prior to mouseout
    event so that I can access the iframe and click on a link inside the
    iframe object.

    Regards,
    Suvajit
    jeet_sen, Mar 23, 2006
    #1
    1. Advertising

  2. jeet_sen

    marss Guest

    jeet_sen wrote:
    > Hi,
    > I have generated a table and have attached a pop up to display at
    > onmouseover event of each cell.
    > For each cell the pop up will display cell specific detailed data. I
    > have generated the pop up using iframe and it is working fine.
    > On mouseout event of each cell I have destroyed the created the
    > iframe.
    > This is working fine.
    > But if I try to move the cursor over the iframe, the mouseout event
    > is fired and my iframe is vanishing off.
    > Can anyone let me know which event i can attach prior to mouseout
    > event so that I can access the iframe and click on a link inside the
    > iframe object.
    >
    > Regards,
    > Suvajit


    You can hide popup not immediately but after some delay. I put here
    some pseudocode as example:

    html:
    <td onmouseout="mouseOutCell()" .....

    code:
    var hidePopupTimeout = null;

    function mouseOutCell()
    {
    hidePopupAfterTimeout();

    //f means iframe object
    f.contentWindow.document.onmouseover = mouseOverIFrame;
    f.contentWindow.document.onmouseout =
    hidePopupAfterTimeout;
    }

    function mouseOverIFrame()
    {
    if (hidePopupTimeout)
    clearTimeout(hidePopupTimeout);
    }

    function hidePopupAfterTimeout()
    {
    if (hidePopupTimeout)
    clearTimeout(hidePopupTimeout);
    hidePopupTimeout = setTimeout("hidePopup()", 500);
    }

    function hidePopup()
    {
    //.......
    }

    Maybe it helps.
    marss, Mar 23, 2006
    #2
    1. Advertising

  3. jeet_sen

    jeet_sen Guest

    Hi marss,
    Yes !!! It worked as I wanted. Thanks a lot.
    Regards,
    Suvajit
    jeet_sen, Mar 24, 2006
    #3
  4. jeet_sen

    jeet_sen Guest

    Hi,
    My Iframe contains a link. This link is actually a local text file. I
    made this link to call a function openWindow to display the content of
    the local file in a new window. My openWindow fucntion looks like this:
    function openNewWindow(url)
    {
    new_window = window.open(url,'Log
    details','toolbar=0,menubar=0,resizable=1,dependent=1,status=0,width=400,height=300,left=25,top=25');
    }

    And my iframe code is as follows:

    var contents = document.createElement('IFRAME');
    contents.contentDocument.write(msg);
    msg = "<BR><span style='color:" + col + "; font-size:11pt'><b>" + name
    + ' : </b><a href=javascript:eek:penWindow("file://' + value + '")>' +
    value + '</a></span>';
    contents.contentDocument.write(msg);

    where value is a valid pathname to a text file.

    But everytime I click this hyperlink javascript states : openWindow is
    not defined

    I defined the openWindowd function in contents.src .i.e detailBox.html

    Where I am going wrong?
    jeet_sen, Mar 27, 2006
    #4
  5. jeet_sen

    marss Guest

    jeet_sen wrote:
    .....
    > function openNewWindow(url)
    > {

    .....
    >
    > var contents = document.createElement('IFRAME');
    > contents.contentDocument.write(msg);
    > msg = "<BR><span style='color:" + col + "; font-size:11pt'><b>" + name
    > + ' : </b><a href=javascript:eek:penWindow("file://' + value + '")>' +
    > value + '</a></span>';
    > contents.contentDocument.write(msg);
    >
    > where value is a valid pathname to a text file.
    >
    > But everytime I click this hyperlink javascript states : openWindow is
    > not defined
    >
    > I defined the openWindowd function in contents.src .i.e detailBox.html
    >
    > Where I am going wrong?


    Maybe you are simply made a mistake: define function "openNewWindow"
    and call "openWindow"?
    marss, Mar 27, 2006
    #5
  6. jeet_sen

    jeet_sen Guest

    Hi marss,
    No I have checked that out. My mail composition had the error.
    But can you tell me that whether it is possible to open an new window
    from an iframe dynamically.
    jeet_sen, Mar 28, 2006
    #6
  7. jeet_sen

    marss Guest

    jeet_sen wrote:

    > My Iframe contains a link. This link is actually a local text file. I
    > made this link to call a function openWindow to display the content of
    > the local file in a new window. e to a text file.

    ......

    > I defined the openWindowd function in contents.src .i.e detailBox.html
    >
    > Where I am going wrong?


    If you need to load some url in the iframe and add additional elements
    after it, you should not use document.write() method because it opens
    and clears the document(of course, if the document is not in the
    process of being opened and written). The additional elements have to
    be added as objects (use document.createElement()).

    function loadFrame()
    {
    var contents = document.createElement('IFRAME');
    contents.id="frmId";
    contents.src="frame.htm";
    document.body.appendChild(contents);
    //set delay before element addition
    setTimeout("addAdditionalElements()", 50);
    }

    function addAdditionalElements()
    {
    var f = document.getElementById("frmId");
    var div = f.contentWindow.document.createElement("DIV");
    div.innerHTML = "<a
    href='javascript:eek:penWindow(\"http://some.html\");'>Click</a>";
    f.contentWindow.document.body.appendChild(div);
    }

    There is an important aspect of referencing a newly created window. IE
    tends to race ahead of script execution (presumably to improve
    performance). The downside of this feature is that in the case of a
    newly created external object, a reference to the new object may not be
    valid when the subsequent statements execute in the shadows. To prevent
    this race-ahead execution from causing script errors, you need to place
    statements referencing the object in a separate function that begins
    executing after the current function thread completes. The setTimeout()
    method is the mechanism that assists in this task.

    Besides, I advise to remove space in a new window name in the
    openWindow() function:
    new_window = window.open(url,'Logdetails'..
    instead of
    new_window = window.open(url,'Log details'...
    It cause "Invalid argument" error in IE.
    marss, Mar 28, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff
    Replies:
    2
    Views:
    929
    clintonG
    Sep 19, 2006
  2. mi
    Replies:
    4
    Views:
    13,444
    dorayme
    May 21, 2008
  3. Ryan Taylor
    Replies:
    1
    Views:
    674
    Ryan Taylor
    Sep 9, 2004
  4. Daedalous
    Replies:
    3
    Views:
    663
    Daedalous
    Jan 16, 2004
  5. nc
    Replies:
    0
    Views:
    138
Loading...

Share This Page