DalTXColtsFan
asked on
JavaScript equivalent to Server.CreateObject on *client* side
Greetings experts,
How could I use JavaScript to launch, for example, Microsoft Excel or any other application that supports OLE Automation on the *client* machine? Basically, the equivalent of Visual Basic's CreateObject command, but I want the application launched on the client.
In this specific example, I have an ASP application hitting a database that has files created by an OLE application saved as BLOBs, and I want to allow the ASP user to click a link, launch the app on their PC and open the file.
Can I do this with JavaScript?
Thanks
Joe
How could I use JavaScript to launch, for example, Microsoft Excel or any other application that supports OLE Automation on the *client* machine? Basically, the equivalent of Visual Basic's CreateObject command, but I want the application launched on the client.
In this specific example, I have an ASP application hitting a database that has files created by an OLE application saved as BLOBs, and I want to allow the ASP user to click a link, launch the app on their PC and open the file.
Can I do this with JavaScript?
Thanks
Joe
> VBSCRIPT would be your opton...
This is the object that would be used .... new ActiveXObject("Shell.Appli cation")
This is the object that would be used .... new ActiveXObject("Shell.Appli
ASKER
Is ActiveXObject a JavaScript command or a VBScript command?
vbscript !
Hey, isn't there an EMBED tag in HTML???
The same functionality is also provided by OBJECT tag.
I can't think of a more neat way of doing it.
The same functionality is also provided by OBJECT tag.
I can't think of a more neat way of doing it.
ActiveX would, of course, only work with the proper security settings. And only on Internet Explorer. So it would only be really feasible for an intranet application.
And, IIRC (since I don't use ActiveX ever),
new ActiveXObject("Shell.Appli cation") is Javascript,
CreateObject("Shell.Applic ation") is vbscript.
I could be wrong about this.
And, IIRC (since I don't use ActiveX ever),
new ActiveXObject("Shell.Appli
CreateObject("Shell.Applic
I could be wrong about this.
Hello buddies ;-)
Hi Joe,
you need not to do anything on client side.
Simply extract the xsl files from the BLOB to your server directory and propose to the browser a link on the page to those xsl file.
The user can now click on the link and is asked wether he want to download the xsl file or to open it with his Excel application. That's all.
Hi Joe,
you need not to do anything on client side.
Simply extract the xsl files from the BLOB to your server directory and propose to the browser a link on the page to those xsl file.
The user can now click on the link and is asked wether he want to download the xsl file or to open it with his Excel application. That's all.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The xls files are stored on web server in database records as BLOBs, right?
ASKER
I decided to boost the points here because it looks like I have a bigger problem than I thought.
I'm modifying an ASP application that uses a mix of ASP, VBScript and JavaScript. I was tasked with adding a menu item that when clicked would open the application on the client and have the application open the current file from the database (the app has its own OLE Automation method for opening a file from the database).
Here is my the code that adds the menu item (link) to the page:
<TD>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%" class="MNLevel2Row">
<TR valign="center" onclick="javascript:OpenPo g('17')">
<TD class="MNLevel2Item">Open in Space Planning</TD>
<TD> </TD >
</TR></TABLE>
</TD>
A whole bunch of other functions are called from this page that are #included in another file. The top of the file includes this line:
<%@ CodePage=65001 Language="VBScript"%>
but most of the functions *on* the page are clearly JavaScript, not VBScript, for example:
Sub GoStr(variUserID)
parent.frames.item(0).docu ment.all.i tem("paged esc").inne rtext = "<%=Resource1020%>"
parent.frames.item(1).loca tion.href = "NavBar.asp?UserID=" & variUserID
parent.frames.item(2).loca tion.href = "Objsel.asp?UserID=" & variUserID
End Sub
so I added my function to this page. Here is my code:
Sub OpenPog(varCurrentFileDBKe y)
alert("try")
var objPSApp = new ActiveXObject("MyOLEServer .Applicati on")
objPSApp.Visible = True
objPSApp.LoadFileFromDatab ase(varCur rentFileDB Key)
End Sub
If I comment out the lines after the alert call and click the link, I see the try messagebox. If I uncomment those lines, I get "Error: Expected end of statement".
What am I up against here? I tried putting semicolons at the ends of the lines but it gave me a syntax error.
Thanks
Joe
I'm modifying an ASP application that uses a mix of ASP, VBScript and JavaScript. I was tasked with adding a menu item that when clicked would open the application on the client and have the application open the current file from the database (the app has its own OLE Automation method for opening a file from the database).
Here is my the code that adds the menu item (link) to the page:
<TD>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%" class="MNLevel2Row">
<TR valign="center" onclick="javascript:OpenPo
<TD class="MNLevel2Item">Open in Space Planning</TD>
<TD> </TD
</TR></TABLE>
</TD>
A whole bunch of other functions are called from this page that are #included in another file. The top of the file includes this line:
<%@ CodePage=65001 Language="VBScript"%>
but most of the functions *on* the page are clearly JavaScript, not VBScript, for example:
Sub GoStr(variUserID)
parent.frames.item(0).docu
parent.frames.item(1).loca
parent.frames.item(2).loca
End Sub
so I added my function to this page. Here is my code:
Sub OpenPog(varCurrentFileDBKe
alert("try")
var objPSApp = new ActiveXObject("MyOLEServer
objPSApp.Visible = True
objPSApp.LoadFileFromDatab
End Sub
If I comment out the lines after the alert call and click the link, I see the try messagebox. If I uncomment those lines, I get "Error: Expected end of statement".
What am I up against here? I tried putting semicolons at the ends of the lines but it gave me a syntax error.
Thanks
Joe
Hi Joe,
'Sub' is not javascript; javascript is c-like, requiring function keyword & braces:
function OpenPog(varCurrentFileDBKe y)
{
alert("try")
var objPSApp = new ActiveXObject("MyOLEServer .Applicati on")
objPSApp.Visible = True
objPSApp.LoadFileFromDatab ase(varCur rentFileDB Key)
}
see the code I posted above.
Vinny
'Sub' is not javascript; javascript is c-like, requiring function keyword & braces:
function OpenPog(varCurrentFileDBKe
{
alert("try")
var objPSApp = new ActiveXObject("MyOLEServer
objPSApp.Visible = True
objPSApp.LoadFileFromDatab
}
see the code I posted above.
Vinny
ASKER
Vinny,
I tried it that way and got an invalid character error.
This is what's confusing me.
From the HTML generated by the ASP:
javascript:GoPlan('819199' ,'1','17')
Yet in the ASP page containing the function GoPlnStatus:
<%@ CodePage=65001 Language="VBScript"%>
<!-- #include file="Net_Res_Strings.asp" -->
Sub OpenPog(niPogDBKey)
alert("try")
var objPSApp = new ActiveXObject("ProSpace.Ap plication" )
objPSApp.Visible = True
End Sub
Sub GoPlan(variUserID, variDBStoreKey, variDBPlanogramKey)
parent.frames.item(0).docu ment.all.i tem("paged esc").inne rtext = "<%=Resource1022%>"
'parent.frames.item(1).loc ation.href = "Left_NavBar.asp?UserID=" & variUserID & "&DBStoreKey=" & variDBStoreKey & "&DBPlanogramKey=" & variDBPlanogramKey
parent.frames.item(2).loca tion.href = "PlnStatus.asp?UserID=" & variUserID & "&DBStoreKey=" & variDBStoreKey & "&DBPlanogramKey=" & variDBPlanogramKey
End Sub
So the calling HTML says javascript, but the script language in the file is VBScript and there are Sub keywords, no braces and no semicolons.
Yet keywords like parent.frames.item etc - those are exclusively javascript aren't they? And isn't alert a javascript-only keyword? I tried using MessageBox there and it didn't display the messagebox. Didn't throw an error though.
Help me somebody, please - I'm horribly confused!!!!!!!!!
I tried it that way and got an invalid character error.
This is what's confusing me.
From the HTML generated by the ASP:
javascript:GoPlan('819199'
Yet in the ASP page containing the function GoPlnStatus:
<%@ CodePage=65001 Language="VBScript"%>
<!-- #include file="Net_Res_Strings.asp"
Sub OpenPog(niPogDBKey)
alert("try")
var objPSApp = new ActiveXObject("ProSpace.Ap
objPSApp.Visible = True
End Sub
Sub GoPlan(variUserID, variDBStoreKey, variDBPlanogramKey)
parent.frames.item(0).docu
'parent.frames.item(1).loc
parent.frames.item(2).loca
End Sub
So the calling HTML says javascript, but the script language in the file is VBScript and there are Sub keywords, no braces and no semicolons.
Yet keywords like parent.frames.item etc - those are exclusively javascript aren't they? And isn't alert a javascript-only keyword? I tried using MessageBox there and it didn't display the messagebox. Didn't throw an error though.
Help me somebody, please - I'm horribly confused!!!!!!!!!
Joe,
My mistake... Instead of New ActiveXObject... try using server.CreateObject...(thi s is vbscript and other one is JScript)
My mistake... Instead of New ActiveXObject... try using server.CreateObject...(thi
ASKER
But won't Server.CreateObject create the object on the server, not the client? I want the object created on the client, using client resources.
Thanks
Joe
Thanks
Joe
Then you could either a make an ActiveXObject in javascript, but ( as posted before ) you have to worry about browser security and what not ...
or you could use CreateObject in vbscript , but i do belive the same security issues come into effect ( or is it affect? )
or you could use CreateObject in vbscript , but i do belive the same security issues come into effect ( or is it affect? )
Since the context is server.. I don't think it can !
Hi Joe,
Are you saying that you wrote the function as a javascript function (complete with <script...> tags, and that the ASP is changing it to vbScript?????? Or, are you saying someone else wrote the routine as vbscript?
Cut & paste the code I provided, and embed it within <script..> tags (as demonstrated above)
parent.frames.item is part of the DOM (document object model), and as such is part of HTML, not javascript, not vbscript, not asp -- though all three can manipulate it.
Regarding the invalid character code message -- which line and what does it say exactly? Sometimes there is a null character being interpreted; try deleting the line and rewriting it.
Vinny
Are you saying that you wrote the function as a javascript function (complete with <script...> tags, and that the ASP is changing it to vbScript?????? Or, are you saying someone else wrote the routine as vbscript?
Cut & paste the code I provided, and embed it within <script..> tags (as demonstrated above)
parent.frames.item is part of the DOM (document object model), and as such is part of HTML, not javascript, not vbscript, not asp -- though all three can manipulate it.
Regarding the invalid character code message -- which line and what does it say exactly? Sometimes there is a null character being interpreted; try deleting the line and rewriting it.
Vinny
Hi Venabili,
Whatever you decide is fine by me (though I suspect he found the errant character and thus solved his problem)
Vinny
Whatever you decide is fine by me (though I suspect he found the errant character and thus solved his problem)
Vinny
~Hemanth