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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending RightClick>Save as?

Status
Not open for further replies.

Cheech

Technical User
Nov 6, 2000
2,933
0
0
EU
Hi

I am trying to link to zipped files on a shared network server from an Intranet server. This means that the save/open dialogue box is not opened when a link is used.

I was wondering if anyone has got a function that will send the browser "RightClick>Save As" command when a link is clicked with the normal left button?

I know that the force download question is debated over and again but didnt know if the above was possible?

Cheech

[Peace][Pipe]
 
In IE try:

<input type=&quot;button&quot; onclick=&quot;document.execCommand('SaveAs')&quot; value=&quot;Save&quot;>

Adam
while(ignorance==true){perpetuate(violence,fear,hatred);life--};
 
Cheers for the reply Adam,

I wrapped a href round that and all it does is try to save the html page it sits in? I tried 3 methods as below:
Code:
<A href=&quot;[URL unfurl="true"]http://servername/folder/test.zip&quot;><input[/URL] type=&quot;button&quot; onclick=&quot;document.execCommand('SaveAs')&quot; value=&quot;Save&quot;></A>

and

<A href=&quot;file://servername/folder/test.zip&quot;><input type=&quot;button&quot; onclick=&quot;document.execCommand('SaveAs')&quot; value=&quot;Save&quot;></A>

and

<A href=&quot;file://servername/folder/test.zip&quot; onclick=&quot;document.execCommand('SaveAs')&quot;>Click here</A>
all of these just tried to save the page they were on not the target test.zip

Any suggestions?

Cheech


[Peace][Pipe]
 
JScript does not allow you to save markup to file, it only fires the browser &quot;save as...&quot; option.

There is no fool proof fix. It appears to be an intentional limitation to prevent HTA being too competitive.

You can still post to the server, and have it save the contents server side, or export the contents as an unsupported file type that MSIE then download/saves to disk.

If it's returned as a HTML file then MSIE will automatically add it's markup tags and you're back where you started.

You can add a true &quot;save&quot; option using Visual Basic runtimes but you gotta pay for the licence (see why they don't want HTA being too good?) and also, it slows down your program an awful lot.

Hope this information is valuable to you :)

----------
I'm willing to trade custom scripts for... [see profile]
 
Oops. I misread the thread ;)

Humn.. with regards to the original question. I think you may be able to use WScript or ActiveX to launch the file.

----------
I'm willing to trade custom scripts for... [see profile]
 
I'm not too great with WScript, but this comes from a script of mine and it may be helpful in leading to a more complete answer.

Not sure what happens when you run a ZIP file. It may cause the save dialog to popup? Untested.

Best of luck with it :)

Code:
function clickProg(prog) { 
var WScript=new ActiveXObject(&quot;WScript.Shell&quot;);
WScript.Run(prog);
var WScript=null;
}

----------
I'm willing to trade custom scripts for... [see profile]
 
Sorry, I totally missed what you were trying to do. Open IIS on your Intranet server and create a virtual directory to the share drive. Then you can create a link like
Code:
[URL unfurl="true"]http://yourServer/virtualDirectory/myZip.zip[/URL]
which will give you the Save As dialog you want.

Another option is to use an ActiveX script like stormbind said. has a download script you can try for free. It would be much easier to try the first solution though.

Adam
while(ignorance==true){perpetuate(violence,fear,hatred);life--};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top