View Full Version : dhtml window widget (iframe type bug)

05-19-2008, 10:52 AM
1) Script Title: DHTML Window Widget (v1.1)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/

3) Describe problem:

hi all, i got a problem on this dhtml window widget when i'm using iframe type of dhtml windows..
here is the problem : i need the page to setfocus on the dhtmlwindow (iframe type) whereever i click on the dhtml window, not only on the drag handler. this problem occurs only when i'm using the iframe type.

example using the url above : when the page load there're 2 dhtml window, #1 is the google website (using iframe type), the #2 one is broadcast title (inline type). when i click on the #2 it will setfocus and bring that window to the top, then i need to get back to the google website (#1) and i just click on the body of the dhtmlwindow(not on the draghandler) and it won't setfocus though i can type on the textfield etc..

i need the iframe type dhtmlwindow to setfocus whereever i clicked the dhtml window, whether it's on the body of the iframe, or the draghandler..

anyone can help?
ddrive is cool..but i think it'll be much better that way...

05-19-2008, 08:41 PM
Unless the page contained in the IFRAME is from your own domain, it's not possible to set focus on the DHTML window when the IFRAME area is clicked on. This is due to cross browser JavaScript limitations. Lets say you're showing Google.com inside the DHTML window- there's no way for the script to react to when the user clicks within the Google page, as that action occurred outside your own domain.

05-21-2008, 02:56 AM
ok, the pages i opened in the dhtml window is my own pages, which i can modify as my wish..
but, how do i make the page to access the parent's objects(to setfocus itself)?
i can't find the event handler onClick on the <body> tag.should i put the onClick event handler on any object of the page?

05-21-2008, 06:03 AM
Well, if the page contained in your IFRAME is within your domain, setting focus on the DHTML window when the user clicks inside the IFRAME is possible, yep. Lets say the window is opened via the code:

var mywin=dhtmlwindow.open("pagebox", "iframe", "test.htm", "My pets", "width=590px,height=350px,resize=1,scrolling=1,center=1")

Inside test.htm, you'd add the following to the BODY tag to enable focus onclick:

<body onclick="parent.dhtmlwindow.setfocus(parent.mywin)">

Notice the part in bold, which should match up with the variable instance name you assigned at the beginning.

05-21-2008, 08:40 AM
ok thx so much buddy...
it works...
God bless you

08-26-2012, 09:28 PM
Hi, i just found this solution while searching for the exact same issue, however it's not working for me!?
I'm using the below script to open multiple windows, each with a unique indentifier, the page in the iframe has this bodytag: <body onClick="parent.dhtmlwindow.setfocus(parent.iframewindow)"> however there's no focus on click inside the window.

<script type="text/javascript">
function openmenu_iframe(url,title,id){
// this opens a centered window, each unique id will have it's own window
iframewindow=dhtmlwindow.open(id, "iframe", url, title, "width=1000px,height=600px,center=1,resize=1,scrolling=1")

Any ideas?