...

View Full Version : Clicking within a frame



nca
01-21-2006, 05:39 PM
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:



<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>

vwphillips
01-21-2006, 08:25 PM
can be done

this is a rough example


<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


<!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


<!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


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); }

nca
01-26-2006, 07:17 AM
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?

glenngv
01-26-2006, 09:58 AM
For security reasons, javascript has no access to the page that is on another domain.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum