Window. open () reports an error in IE8, the output file cannot be downloaded, and the problem of opening multiple Windows repeatedly occurs.

Source: Internet
Author: User
Tags blank page

Use the PHP header in the business to export the DOC file, get the value to the page, and read the corresponding data output to download the DOC file. The user proposed the need for batch, So he designed the JS to loop out the corresponding number of windows. open (), input different values to the page, and output the corresponding files in batches. To put it simply, I need to loop out multiple windows. open ().

JS Code:

VaR outcode = JSON. parse (<? PHP echo $ jsoncode;?> ); For (VAR I = 0; I <outcode. length; I ++) {$ statu = $ ("start to export" + outcode [I] + "Application Form .. "). appendto ("body"); window. open (".. /docout. PHP? Id = "+ outcode [I]); $ statu. append (" Download popped up, please note ");}

(PHP page omitted)

In the actual process, several problems occur on IE8. It takes a lot of time. The following lists all the problems encountered (all in IE8. Vomit ).

1. First, you need to open a single page that outputs the doc using the PHP header, and find that you are using <a href = "url. php? Id = Code "> when the link is passed, the new window is opened normally and the file is prompted to be downloaded. Instead, use window. open () to open a blank page.

Find a solution for surfing the Internet: reset ie personalization settings to the default (tools-Internet Options-advanced-reset), delete all personalized settings, and then retry IE, the window can be opened normally. However, there is another problem: the download error is reported after the pop-up window appears, and the prompt "the site cannot be opened, the requested site is unavailable "...

After finding the solution, we found that it was a cache bug of IE8, which requires a patch. Or change the cache mode in the PHP output.

Solve the problem after adding the header statement.

header("Cache-Control: must-revalidate, post-check=0, pre-check=0");

2. Multiple windows. the open pop-up problem is solved in a single way. When multiple windows are displayed in the batch loop pop-up window, IE8 displays the following phenomenon: the loop starts, after opening the first window (opened in the tab by default), the previous window is closed and opened each time. The previous window is repeatedly opened, and only one window can be opened and the content cannot be output. It is suspected that multiple windows. Open can only be located in one window.

For more information, the parameters of window. Open include (URL, name, feature, replace ):

URL: Window link, indicating the urlname of the document to be displayed in the new window: name of the new window. If an existing window is specified, a new window is not created, but a reference to the specified window is returned. Feature: style customization, such as high width, scroll bar, etc. Replace: URL entry Generation Method in history, true replaces the current entry in browsing history, false creates a new entry in browsing history

Therefore, each window name is assigned a different name and the replace value is set to false. the problem persists.

On Stack Overflow, I found some problems. I found that, first, I mentioned the standard interpretation of the name attribute, in addition to assigning it to a custom string and _ blank _ parent _ self _ top. The details are as follows:

View: msdn's explanation of window. open ()

Change name to "_ blank ".

window.open("../docout.php?id="+outCode[i],"_blank","",false);

Solve the problem. Each window. Open is opened in a new window. But the annoying problem is not over ..

3. This is really a tough time .. The problem still persists after uploading to the server. Changing attributes does not work either. After suffering for a day, I found the problem:

(10 thousand words are omitted during the attempt)

On the local server, the security configuration of the local site in IE8 is medium-low, while that of the Internet is medium-high by default. So I tried to add the site to a trusted site and configure the same medium and low security. Solved the problem... It is estimated that it is a problem of bulletproof windows in security configuration.

Configuration method: Internet option-security-trusted site-add, and set security to medium-and low-level

You can also find the corresponding options at the custom level. You should disable the bullet-proof window and try again.

At this point, this problem can no longer be bypassed by code. You can only remember that you will not use this method to implement any functions next time. There are differences. (Actually all are ie ...)

4. In addition, the question about name in IE8 -- reject spaces and hyphens
In the answer, second, in name, IE8 does not support space (space), dash (dash -), if "My-window" or "My window" is used in name, the invalid argument error is returned.
Sputation: Why can't Ie go to hell.

Refer to related questions on Stack Overflow:

IE8 var W = Window. open ()-"message: invalid argument.

"Window. Open
Not working in IE8?

This article is also published in my independent blog. mc-zone.me, click to visit this article

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.