[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

JavaScript redirect to local file

Posted on 2004-11-08
3
Medium Priority
?
2,126 Views
Last Modified: 2009-07-29
Currently there is an application running that was written in house. In the application there is a JavaScript redirect that will open a PDF file off the local machine, the code is below.

The code worked great on all platforms until XP SP2 came along and then it stopped working and we get a "page cannot be displayed" error. We have tried turning off the pop-up blocker and that wasn't it, so any help would be appreciated.

Can anyoen help with what setting we need to change in IE to get this to work again? Here is the code.

/**
 * buildMidwestActivityReportLinkUrl
 *
 * JavaScript function that builds the Midwest Activity Report link URL with the
 * parameters required for the servlet.
 *
 * Author: Janardan Kortikere
 */
 
function buildMidwestActivityReportLinkUrl()
{
      var sortDirectionsList = document.midwestActivitySortFilterForm.sortDirectionsList.value;
      var hiddenFilterProjectStatusId = document.midwestActivitySortFilterForm.hiddenFilterProjectStatusId.value;
      var hiddenFilterBuildingCode = document.midwestActivitySortFilterForm.hiddenFilterBuildingCode.value;
      var filterDoneByDateFromOffset = document.midwestActivitySortFilterForm.filterDoneByDateFromOffset.value;
      var filterDoneByDateToOffset = document.midwestActivitySortFilterForm.filterDoneByDateToOffset.value;
      var filterDoneByTimeFrom = document.midwestActivitySortFilterForm.filterDoneByTimeFrom.value;
      var filterDoneByTimeTo = document.midwestActivitySortFilterForm.filterDoneByTimeTo.value;

      var midwestActivityReportLink =
            '<%= UrlBuilder.getServletRoot() %><%= ApplicationConstants.SERVLET_PRINT_MIDWEST_ACTIVITY_REPORT %>'
            + '?<%= ApplicationConstants.ACTION %>=<%= ApplicationConstants.ACTION_PREVIEW %>'
            + '&sortDirectionsList=' + sortDirectionsList
            + '&hiddenFilterProjectStatusId=' + hiddenFilterProjectStatusId
            + '&hiddenFilterBuildingCode=' + hiddenFilterBuildingCode
            + '&filterDoneByDateFromOffset=' + filterDoneByDateFromOffset
            + '&filterDoneByDateToOffset=' + filterDoneByDateToOffset
            + '&filterDoneByTimeFrom=' + filterDoneByTimeFrom
            + '&filterDoneByTimeTo=' + filterDoneByTimeTo
            + '&sortField1=' + document.midwestActivitySortFilterForm.sortField1.value
            + '&sortField2=' + document.midwestActivitySortFilterForm.sortField2.value
            + '&sortField3=' + document.midwestActivitySortFilterForm.sortField3.value
            + '&sortField4=' + document.midwestActivitySortFilterForm.sortField4.value
            + '&sortField5=' + document.midwestActivitySortFilterForm.sortField5.value;
      return midwestActivityReportLink;
}
/**
 * showMidwestActivityReportInNewWindow
 *
 * JavaScript function that displays the Midwest Activity Report in a new window.
 *
 * Author: Janardan Kortikere
 */
 
function showMidwestActivityReportInNewWindow()
{
      midwestActivityReportWin=window.open("",                   
            'midwestActivityReportWin',toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=1,width=975,height=700,left=0,top=0');
      midwestActivityReportWin.document.write("<head><title>Midwest Activity Report<\/title><\/head>");
      midwestActivityReportWin.document.write('<h1>' + 'Retrieving report data .... please wait' + '</h1>');
      newURL=buildMidwestActivityReportLinkUrl();
      setTimeout('midwestActivityReportWin.location.href=newURL;', 1000);      
}
0
Comment
Question by:mt_100
1 Comment
 
LVL 49

Accepted Solution

by:
Roonaan earned 500 total points
ID: 12524739
This is because the file:// domain is another domain than the http:// domain. Therefor SP2 does not allow you to change a "online" document to "local" href.

A solution is to have a frame/window with href file:// and then change it using javascript:

<iframe src="file://" id="midwestActivityReportWin"></iframe>

midwestActivityReportWin.location.href = "file://localfile";

Regards, and goodluch,

-r-
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question