-
your onclick value is not a function, it is the result of a function call. Try to change that to
onclick="Open_Excel_File"
; You’ll have to provide the file path at some point -
Accessing file system from browser is super restricted for security matters, the only way I see fit is to have a file input and using what user provides
Solution 1 :
Solution 2 :
Also Plone filter out a bounce of potential “nasty” tags through a specific configurable tool.
It seems to me that you have injected the in the source HTML of a Page (document) type.
If so, you will see in your browser that in, the page source code, the script tag has been totally stripped away.
So,
a correct way to inject some js in your page, is to load it as portal_javascript resource (plone<=4) or in resource_registry (plone>=5).
tha nasty way is to access, in the ZMI, at https://yourseite:8080/Plone/portal_transforms/safe_html/
and configure it to accept script tags inside a document (all document in your site actually).
If this answer does not satisfy you try to ask in the official community:
http://community.plone.org
hth,
alessandro
Problem :
I am editing a plone page to open an Excel document on a specific sheet. I created two buttons to see if either would appear as actual buttons and use the JS function I reference. With this code the exact part of the page looks like the image below.
Why is only text showing instead of the button and why is the onclick attribute not working?
Note: I have changed to links to the spreadsheet for posting it on here but the link has been tested on other webpages
<script type="text/javascript">
function Open_Excel_File(path,sheet)
{
fso = new ActiveXObject("Scripting.FileSystemObject");
if (!fso.FileExists(path))
alert("Cannot open file.nFile '" + path + "' doesn't exist.");
else
{
var myApp = new ActiveXObject("Excel.Application");
if (myApp != null)
{
myApp.visible = true;
Book = myApp.workbooks.open(path);
var excel_sheet = Book.Worksheets(sheet).Activate;
myApp.range(f_range).Select;
}
else {
alert ("Cannot open Excel application");
}
}
}
</script>
<div>
<button onclick='Open_Excel_File("file://///fs-01DepartmentsUnderwritingStatistical%20Data%20and%20Medical%20InformationStatisticsCancersCancer%20Statistics%Cancer%20Statistics%.xlsx", "Vulvar Ca");'>Open File</button>
<input type="button" onclick="Open_Excel_File('file://///fs-01depsuwstat%20Data%20and%20Medical%20InformationStatisticsCancersCancer%20Statistics%202018Cancer%20Statistics%.xlsx', 'VCA');'>OPEN FILE</input>
</div>
Comments
Comment posted by Zohaib Ijaz
which phone? android or iphone?
Comment posted by Ocheezy
@ZohaibIjaz Plone the CMS
Comment posted by Bryan Elliott
So what is your question? There is no question.
Comment posted by Ocheezy
@BryanElliott I have just updated my post to include a direct question.
Comment posted by random
@O’Cheezy –