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 4 of 4
  1. #1
    nca
    nca is offline
    New Coder
    Join Date
    Dec 2003
    Posts
    39
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Question Clicking within a frame

    Would it be possible to have javascript detect if anything is clicked within a frame in a 2 frame window?

    Such as this example:

    Have a window open that is divided into 2 frames, a top and bottom. Would it be possible for the top frame to contain a script to know if anything has been clicked within the bottom frame's contents?

    or I could have have a page open a new window and report back to the first page if anything has been clicked within the new window?

    I am running a page exchange and would like to implement the feature of knowing if a member actually clicks on any links within the page that is being displayed.

    Any thoughts are GREATLY appreciated.


    Here is my example frame window:

    PHP Code:
    <html>

    <
    head><title>Site</title></head>

    <
    frameset rows="45,*" framespacing="0" border="0" frameborder="0">

        <
    frame name="top" scrolling="no" noresize src="topframe.php">
        
        <
    frame name="bottom" noresize SCROLLING="yes" src="http://www.SiteThatIWantToKnowIfClickedOn.com">
            
        <
    noframes>
        <
    body><p>This page uses frames and your browser does not support them.</p></body>
        </
    noframes>

    </
    frameset>

    </
    html

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,503
    Thanks
    3
    Thanked 500 Times in 487 Posts
    can be done

    this is a rough example

    Code:
    <html>
    <head>
    <title>No title</title>
    <meta name="description" content="Makes a menu frame in the left. Hyperlinks in the menu frame are targeted to the main frame.">
    </head>
    <frameset rows="1*" cols="20%, 80%">
    <frame name="contents" src="DocClick2.htm" scrolling="auto" marginwidth="10" marginheight="14" namo_target_frame="detail">
    <frame name="detail" scrolling="yes" marginwidth="10" marginheight="14">
    <noframes>
    <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
    
    <p>You need a browser that supports frame to veiw this page.</p>
    </body>
    </noframes>
    </frameset>
    </html>
    DocClick2.htm
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    
    <script language="JavaScript" type="text/javascript">
    <!--
    
    function Link(url){
     window.top.detail.location=url;
    document.Show.Show3.value=window.top.detail.document;
     setTimeout('Link2()',2000);
    }
    function Link2(url){
      obj=window.top.detail.document;
     scpt=obj.createElement('SCRIPT');
     scpt.type='text/javascript';
     scpt.src='DocClick.js';
     obj.getElementsByTagName('HEAD')[0].appendChild(scpt);
     txt=obj.createTextNode('SCRIPT');
     obj.getElementsByTagName('BODY')[0].appendChild(txt);
    document.Show.Show4.value=obj.getElementsByTagName('INPUT').length;
    
    }
    
    function Rx(obj){
    document.Show.Show1.value=obj;
    
    }
    //-->
    </script>
    <body>
    <span onclick="Link('DocClick1.htm');" >LINK</span>text
    <script> vic=0; </script>
    <form name=Show id=Show style="position:absolute;visibility:visible;top:450px;left:0px;" >
    <input size=10 name=Show1 >
    <input size=10 name=Show2 >
    <input size=10 name=Show3 >
    <input size=10 name=Show4 >
    <input size=10 name=Show5 >
    <input size=10 name=Show6 >
    </form>
    </body>
    
    </html>
    DocClick1.htm
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    
    
    </head>
    
    <body>
    text
    <script> vic=0; </script>
    <form name=Show id=Show style="position:absolute;visibility:visible;top:450px;left:0px;" >
    <input size=10 name=Show1 >
    <input size=10 name=Show2 >
    <input size=10 name=Show3 >
    <input size=10 name=Show4 >
    <input size=10 name=Show5 >
    <input size=10 name=Show6 >
    </form>
    </body>
    
    </html>
    opps forgot the DocClick.js
    Code:
    function zxcDocClick(e){
     document.Show.Show1.value=vic++;
     if (!zxce) var zxce=window.event;
     if (zxce.target) zxceobj=zxce.target;
     else if (zxce.srcElement) zxceobj=zxce.srcElement;
     if (zxceobj.nodeType==3) zxceobj=tt_eobj.parentNode;
     document.Show.Show2.value=zxceobj;
     window.top.contents.Rx(zxceobj.tagName);
    }
    
    
    alert('fred');
    
    document.onclick=function(event){ zxcDocClick(event); }
    Last edited by vwphillips; 01-21-2006 at 08:28 PM.

  • #3
    nca
    nca is offline
    New Coder
    Join Date
    Dec 2003
    Posts
    39
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Hi,
    Thanks for the reply, I have applied the examples you gave me into a workable version on my desktop and played around in IE with it. It does not alert or do anything when the main frame is clicked.
    I want the ability to open a page that is a frame, with top and bottom. Top being mysite.com/top.html and the bottom being a variable site such as www.ebay.com. I want the top frame alerted or some kind of notice that the bottom frame has been clicked within.
    Any other suggestions?

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    For security reasons, javascript has no access to the page that is on another domain.


  •  

    Posting Permissions

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