Is there a way to pass url parameters to a web server when calling window.open() on a file (.doc)?
My problem is that when I call window.open to open a file (on c:) from a javascript function, a request is made to the (coldfusion) web server to reload the current page (which is weird b/c I'm not even using a submit type input):
viewAttachments.cfm
function viewFile(selectbox) {
var selItem = selectbox.options[selectbox.selectedIndex].text;
var selValue = selectbox.options[selectbox.selectedIndex].value;
var filePath = selValue + '\\' + selItem;
window.open(filePath);
}
<cfform name="gridForm" method="post">
<table>
<tr><td>
<cfset destination = expandPath("./cold_case_files")>
<cfdirectory directory="#destination#" action="list" name="fileList" type="file" >
<select id="fileName" name="fileName">
<cfoutput>
<cfloop query="fileList">
<option value="#directory#" >#fileList.Name#</option>
</cfloop>
</cfoutput>
</select>
</td></tr>
<tr><td>
<input type="image" src="btn.jpg" name="view" onClick="viewFile(fileName);return false;" />
</td></tr>
</table>
</cfform>
This is a problem b/c there are coldfusion references to the url parameters throughout the document (passed in when the page is first loaded), which causes a "url parameter not found" exception:
var ProjID = <cfoutput>#url.ProjID#</cfoutput>;
I tried calling window.open with the various values for the name
parameter to prevent the viewAttachments.cfm from reloading:
window.open(URL,name,specs,replace)
- _blank - URL is loaded into a new window. This is default
- _parent - URL is loaded into the parent frame
- _self - URL replaces the current page
- _top - URL replaces any framesets that may be loaded
So my two options are either to prevent the calling page to reload when window.open() is fired, or figure out how to pass in url parameters to the call.
The really weird thing is that the page works on the production site that I copied the code from. I was told by the upper brass that it is not a web server config or application settings issue, so I'm at a loss.
Gratzi.