Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to create a MsComDlg.CommonDialog object in javascript

Status
Not open for further replies.

csq

Programmer
Feb 6, 2001
6
AU
Hi all expert,

I have a question to ask:

I want to put a button on htm file which can open a dialog I can select file from local drive, it is like a <input type=&quot;file&quot;> but because <input type=&quot;file&quot;> can't preset the value.

but when I use
var cdl = new ActiveXObject(&quot;MsComDlg.CommonDialog&quot;);
to create a commondialog object, it doesn't work. It shows
Automation server can't create object error.

attached is my code. I use window2000/IE5.5/Office2000.

<html>
<head></head>
<script >
function getfile( ){
var cdl = new ActiveXObject(&quot;MsComDlg.CommonDialog&quot;);
cdl.showopen;
this.document.form1.txtFile.value = cdl.filename;
}
</script>
<form name=&quot;form1&quot;>
<input type = &quot;text&quot; name = &quot;txtFile&quot; >
<input type = &quot;button&quot; value = &quot;Browse ...&quot; onClick=&quot;getfile )&quot; >
</form>
</html>


Thanks.


Megi





 
well, you're missing a ( in your code... i'm not sure if its a typo or not, but you need a ( in your funtion call... adam@aauser.com
 
Thank you, it is missing a (, it is because my copy mistake.
But it is not that problem.
 
Sorry for my ignorance, but how is it supposed to wrok at all??? I mean <input type=&quot;file&quot;> is the only legal way of accessing the hard drive on a client's machine . That's what I was taught. Is ActiveX control expempt from this rule? Also I think you are only allowed to do this if it is an HTA (HTML Application) sved with this HTA extension. ---
---
 
activex controls can access a clients machine if they allow it... there will be a warning message, then the user gets to pick whether they want to allow it or not. adam@aauser.com
 
Hi.

I think you have to set the MaxFileSize property like this:

...
cdl.MaxFileSize=260;
cdl.ShowOpen();

......

regards, Kirilla
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top