To download files in a project, use Windows. Open to access the download page. However, in IE, you need to set IE8.
Setting method:
If your IE8 icon is on the desktop, right-click the icon and select "properties" to go to IE8 settings. Alternatively, open IE8, select "Tools"-"Internet Options" in the upper-right corner of the toolbar, enter the settings, and click "Settings" in the pop-up property settings window ", then, in the section "when a new window is encountered", select "always open a pop-up window in the new tab ",
In the section "open links from other programs located below", select "New tabs in the current window", and click "OK ".
However, this is not an effective method. As a web project, you cannot tell the user to make complicated settings when the user needs to access it.
How can this problem be achieved?
The page cannot be redirected. The download function is available on this page.
Use the acetionresult returned by mvc3 to download the file. On the page, use window. Location. href = "action" to access this action.
C # code:
Public actionresult about () {return file ("/content/site.css" // file path, "*/Excel" // file type, "dowloa.xls" // download file name );;}
HTML and JS Code
<MCE: Script Type = "text/JavaScript" src = ".. /.. /scripts/jquery-1.4.4.js "mce_src =" scripts/jquery-1.4.4.js "> </MCE: SCRIPT> <MCE: Script Type =" text/JavaScript "> <! -- $ (Document ). ready (function () {$ ('A '). click (function () {window. location. href = "home/about"}); // --> </MCE: SCRIPT> <H2> @ viewbag. message </H2> <p> <A> test </a> </P>
Effect