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

javascript download tweek

Status
Not open for further replies.

siuk

Programmer
Aug 23, 2001
38
0
0
GB
hi,

I was wondering if anyone could help me out. I have a list of html pages kind of a contence page, however when a user clicks on one of the html page link i want a 'save target as' directory box to open.
I know this currently works if your linking to a .zip file, is it possible to prompt this kind of reaction via script? e.g. document.savas.filename

Any ideas?
Can anyone help me out?

Many Thanks

SIuk
 
Hi,

I have one that only seems to work in IE, are you intrested, you may be able to modify it futher?

James
 
yes please, if you could stick it up here that would be great!
 
Hi,

Ok, here goes:

<html>
<head>
<title>Your Page title</title>
</head>

<script language=&quot;javascript&quot;>

// Windows Only
// IE Only
// Does not work within Frames (not tested)
// VALUES: intOLEcmd has these possible values
// OLECMDID_OPEN = 1
// OLECMDID_NEW = 2 warning, this kills IE windows!
// OLECMDID_SAVE = 3
// OLECMDID_SAVEAS = 4
// OLECMDID_SAVECOPYAS = 5 note: does nothing in IE
// OLECMDID_PRINT = 6 note: give '-1' as param - no prompt!
// OLECMDID_PRINTPREVIEW = 7
// OLECMDID_PAGESETUP = 8
// Others have no use in IE

function ieExecWB( intOLEcmd, intOLEparam )
{
// Create OLE Object
var WebBrowser = '<OBJECT ID=&quot;WebBrowser1&quot; WIDTH=0 HEIGHT=0
CLASSID=&quot;CLSID:8856F961-340A-11D0-A96B-00C04FD705A2&quot;></OBJECT>';

// Place Object on page
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);

// if intOLEparam is not defined, set it
if ( ( ! intOLEparam ) || ( intOLEparam < -1 ) || ( intOLEparam > 1 ) )

// THIS IS THE NUMBER YOU MUST CHANGE!!!!!!!!
intOLEparam = 4;

WebBrowser1.ExecWB( intOLEcmd, intOLEparam );
WebBrowser1.outerHTML = &quot;&quot;;
}

</script>
<script>
function saveAsMe (filename)
{
document.execCommand('SaveAs',null,filename)
}
</script>
<body>
<a href=&quot;javascript:saveAsMe('Yourfilename.txt');&quot;>hello</a>
</body>
</html>


Hope this helps somehow!

james
 
Hi,

I forgot to say, please tell me if its any good!

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top