i am having problem in calling javascript function
I want to open a file on click of a link.
Here is my code:
<script language="javascript" type="text/javascript">
var refViewer = null;
function OpenViewerWindow(image) {
return window.open(image, "Viewer", "height=400px,width=550px,menubar=no,scrollbars=yes ,resizable=yes,top=100px,left=234px");
}
function openViewer(image) {
if (refViewer != null) {
if (refViewer.closed == false) {
refViewer.close();
refViewer = OpenViewerWindow(image);
}
else refViewer = OpenViewerWindow(image);
}
else
refViewer = OpenViewerWindow(image);
}
</script>
<a onclick=javascript:openViewer(@ViewBag.path)><img src="pic.jpg"/></a>
and the in the controller:
public ActionResult ActivityPosting(int HobbyDetailID)
{
string filepath = Server.MapPath("~/ePortfolio/PortFolioContent/" + HobbyDetailID + "/ReferenceMaterial/" + item.FilePath);
ViewBag.path = filepath;
return view();
}
The problem is the javascript function does not get called.Please help me
Try this instead in your JavaScript
OpenViewerWindow
function (you need to use thefile://
protocol: