PDA

View Full Version : No such interface supported



perl_geek
10-31-2011, 12:32 PM
Hey there

I've been using Dynamicdrive's dhtml Modal window code with, initially, great success. However, i've now hit a rather large snag. If the pop-up modal window displays a 'regular' HTML form, everthing appears to work okay. But, I also have a requirement to open a previously generated pdf file in a pop-up window and this is where i come unstuck. The pdf document opens and displays fine, the problem comes when i click on the 'X' closewindow button at the top-right of the modal window. When i click this i get a javascript error 'No such interface supported' with the IE8 debugger pointing at line 55 of modal.js...

t.contentDoc=(t.contentarea.datatype=="iframe")? window.frames["_iframe-"+t.id].document : t.contentarea //return reference to modal window DIV (or document object in the case of iframe

As previously stated, i'm using IE8 and it's on a Win XP SP3 machine

If anyonce can shed any light on this issue and, hopefully, provide a solution, that would be great.

Thanks, PG

jscheuer1
10-31-2011, 04:11 PM
IE 8 is correct. Other browsers would probably agree. The script wasn't expecting anything other than an HTML page there. A PDF file has no javascript document object. But you shouldn't need a reference to it to close the dhtml Modal window. I suspect you're using the same dhtml Modal window that you used for the form. That window is probably looking for the form to know whether or not it's allowed to close and/or what it should do as it closes. Perhaps you have something like this:


var agreewin=dhtmlmodal.open("agreebox", "iframe", "modalfiles/agreement.htm", "This Page's Terms of service", "width=590px,height=450px,center=1,resize=1,scrolling=0", "recal")

agreewin.onclose=function(){ //Define custom code to run when window is closed
var theform=this.contentDoc.getElementById("eula") //Access form with id="eula" inside iframe
var yesbox=theform.eulabox[0] //Access the first radio button within form
var nobox=theform.eulabox[1] //Access the second radio button within form
if (yesbox.checked==true)
alert("You agreed to the terms")
else if (nobox.checked==true)
alert("You didn't agree to the terms")
return true //Allow closing of window in both cases
}

Either use a different dhtml Modal window, one without that check. Or you could try this approach (additions changes/highlighted):


var agreewin=dhtmlmodal.open("agreebox", "iframe", "modalfiles/agreement.htm", "This Page's Terms of service", "width=590px,height=450px,center=1,resize=1,scrolling=0", "recal")

agreewin.onclose=function(){ //Define custom code to run when window is closed
var theform;
try { //does this iframe contain a javascript document object?
theform = this.contentDoc.getElementById("eula") //Access form with id="eula" inside iframe
} catch(e){ //if not:
return true; //allow closing of window
}
var yesbox=theform.eulabox[0] //Access the first radio button within form
var nobox=theform.eulabox[1] //Access the second radio button within form
if (yesbox.checked==true)
alert("You agreed to the terms")
else if (nobox.checked==true)
alert("You didn't agree to the terms")
return true //Allow closing of window in both cases
}

The browser cache may need to be cleared and/or the page refreshed to see changes.

There could be other problems. If you want more help:

Please post a link to a page on your site that contains the problematic code so we can check it out.

perl_geek
11-03-2011, 03:51 PM
John

Thanks for the response. I'm not sure if what i've done is correct/wise but it doesn't seem to have done any harm, from what i can see at least. As the line

t.contentDoc=(t.contentarea.datatype=="iframe")? window.frames["_iframe-"+t.id].document : t.contentarea //return reference to modal window DIV (or document object in the case of iframe

was generating the 'No such interface supported' error, i tried commenting out this line. I no longer get the error and have not seen any adverse effects.

Perhaps you could advise if this is not a wise thing to do?

Thanks, PG

jscheuer1
11-03-2011, 04:27 PM
It's OK. But if you need it for a modal - say, one containing a form, it won't be there.

If it was only a problem when you went to close your modal PDF, my solution should work and leave the option for other modals or even other content in the same modal that needs that. But if the error came without having to try to close the modal, we can still probably have it both ways by doing a try/catch on that line.

Then again, if it works and you have no modal iframe that requires a reference to an html document within the modal iframe, I'm pretty sure what you've done is serviceable.