Here's the problem, which only occurs in Internet Explorer (IE). I have a page that has links to several different types of files. Links from these files execute a Javascript function that opens a new window and loads the specific file. This works great, unless the file I need to open in the new window is a PDF in which case the window is blank, even though the URL is in the address field. Refreshing that window using F5 doesn't help. However, if I put the cursor in the address field and press <enter> the PDF loads right up.
This problem only occurs in IE. I have seen it in IE 7 and 8 and am using Adobe Acrobat Reader 9. In Firefox (PC and Mac) everything works perfectly. In Chrome (Mac), the PDF is downloaded. In Safari (Mac) it works. In Opera (Mac) it prompts me to open or save. Basically, everything probably works fine, except for IE.
I have searched for similar problems and have seen some posts where it was suggested to adjust some of the Internet Options on IE. I have tried this but it doesn't help, and the problem wasn't exactly the same anyway.
Here's the Javascript function I use to open the new window.
function newwin(url,w,h) {
win = window.open(url,"temp","width="+w+",height="+h+",menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=auto,resizable=yes");
win.focus();
}
You can see that I pass in the URL as well as the height, h, and width, w, of the window. I've used a function like this for years and as far as I know have never had a problem.
I call the newwin() function using this.
document.pdf
(Yes, I know there are other, better ways than using inline JS, and I've even tried some of them because I've run out of things to try, but nothing works.)
So, if anyone has an idea as to what might be causing this problem, I'd love to hear it.
try:
function newwin(url,w,h) {
var win = window.open("","temp","width="+w+",height="+h+",menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=auto,resizable=yes");
win.location.href = url;
win.focus();
}
I have solved this problem with an invisible iframe
<div id="iframe" style="display: none">
<iframe id="frm" style="display: none"></iframe>
</div>
And this logic here (using jquery):
if ($.browser.msie && ($.browser.version < 9.0)) {
frm.location.href = href;
}
else {
window.open(href);
}
The behaviour in my case is exactly as if the document was opened in a popup, as I'm using
Content-Disposition: attachment; filename="document.pdf"
Related
I have an angular js app and for a print functionality I am opening an html page using the window.open method.
public openNewWindow(html: string, title: string) {
var popupWin = window.open('', '_blank', 'scrollbars=no,menubar=no,toolbar=no,location=no,status=no,titlebar=no, height=500, weidth=900');
popupWin.window.focus();
popupWin.document.write(html);
popupWin.document.title = title;
};
I have a button on the html page to Print. I use the onclick event to call print.
<button class="print-btn" onclick="window.print();" id="view_print"> Print</button>
This code perfectly works in Chrome, but not in IE 11. If I change the default from Edge to IE 10 the print seem to be working and opening the print dialog window. It is definitely slower than the Chrome.
I have tried adding the emulation as below (for IE 10 and 8 etc) but it still does not work.
am I missing anything here? I find a lot of articles but I have not been able to fix it.
Scripted popup windows with size and position parameters are subject to Popup blocker and IE Security zone restrictions. try
window.open('', '_blank');
Use the File>Properties menu to determine which IE Security zone a web page/domain maps to.
See any Wikipedia article side bar for a template method of formatting the current web page in a printer friendly format using media queries.
I am seeing this also, but with the following information:
under Chrome: address at bottom of page is (the correct) http://server/path/file.php?querystring
under IE11: address at bottom of page is http://server/path/{8 digit dynamic alphanumeric string}.htm
The onscreen rendering is correct, but the printed result is a 404 error.
The current work around is to use Chrome.
If you have new system, and after trying everything this is not working out,
Try setting Printer First.
Set Default Printer and your IE should start responding to
"Ctrl" + "P"
or
window.print()
I have this and i can't get it to work on Safari for OS X (Safari 8.0). It works on Firefox and Chrome but i simply cannot get it to work in Safari.
function myChangeHandler()
{
window.open(this.options[this.selectedIndex].getAttribute('value'), '_blank');
this.form.submit();
}
What am i missing?
Thanks
I'm not sure what doesn't work since there is no specific problem that is posted but I'm guessing it's the window.open()?
I found this article
window.open(url, '_blank'); not working on iMac/Safari
it might be the one you were looking for.
From:
Kelly J Andrews
The standard window.open() JavaScript method cannot be used to open a new tab and window from a global HTML file or an extension bar. Instead, the global file and extension bars have access to the SafariApplication, SafariBrowserWindow, and SafariBrowserTab classes, whose methods and properties allow you to work with windows and tabs.
It goes on to explain how you can use
var newTab = safari.self.browserWindow.openTab();
I have been working with a page that redirects a user to either an installed application or a webpage (the fallback). This is called when the page first loads via ClientScript.RegisterStartupScript; the Javascript portion looks something like this:
<script type='text/javascript'>var a = window.location.search; setTimeout(function(){ window.location.pathname = '/Fallback.aspx'}, 500); window.location='myapp://open' + a;</script>
So far, this snippet always functions as expected in Google Chrome, redirecting the user to the Fallback page whenever the 'myapp://open' fails to open correctly within the given amount of time. In Internet Explorer, it only works when the timeout value is set to 100 or lower. My problem at this moment is Firefox, which fails to redirect correctly no matter what the timeout value is set to. (For Firefox, I have tried values of as little as 25 and as high as 2000.)
Does anyone know what the Firefox browser might do differently that would prevent it from redirecting, and if so, is there any known workaround for it?
Thank you very much in advance for your time and advice.
UPDATE: The exact error page I am getting from Firefox is titled "The address wasn't understood", with the description similar to the following: "Firefox doesn't know how to open this address, because the protocol (myapp) isn't associated with any program."
UPDATE: To test this, you can replace '/Fallback.aspx' in the code with 'www.google.com'. If this is tried in IE or Chrome, the browser will fail to open myapp://open and should redirect you to Google instead; this is the intended functionality since the application is not installed. However, in Firefox you will likely be left at the error page telling you the protocol is not recognized; it will fail to redirect to the fallback. I hope this helps, and I apologize for the original wording of my question.
I have found a few different ways to get around this for anyone who may stumble across this question with the same issue. =) The first is by using redirect code in code behind, singling out the Firefox browser which needs to be handled differently:
string userAgent = Request.ServerVariables["HTTP_USER_AGENT"];
if (userAgent.Contains("Firefox") && !userAgent.Contains("Seamonkey"))
{
ClientScript.RegisterStartupScript(this.GetType(), "checkForApp", "<script type='text/javascript'>var a = window.location.search; try { window.location.href='myapp://open' + a; } catch(e) { window.location.pathname = './Fallback'; }</script>"); //Firefox Only
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "checkForApp", "<script type='text/javascript'>var a = window.location.search; setTimeout(function(){ window.location.pathname = './Fallback.aspx'; }, 100); window.location.href='myapp://open' + a;</script>"); // IE & Chrome
}
Although it worked, I do not like this method because it examines the user agent. After this someone suggested to me that I should put an iframe on my fallback page to open the app and just direct everyone to the fallback page instead (which still opens, but if the app is installed, it should open too.) This works in most browsers but not Internet Explorer:
<iframe name="open_app" id="open_app" src="myapp://open" style="height: 1px; width: 1px; visibility:hidden;" ></iframe>
The method I finally decided to go with was an object tag on the fallback page. So far, this seems to work in most major browsers and tested successfully using Chrome, Firefox, Safari, and Internet Explorer. Using this, the fallback page is still opened in the user's browser, but the app will also be opened if it is installed.
<object data="myapp://open<%= Request.Url.Query %>"/>
I am attempting to open an html file in firefox with minimal extras (toolbars, menubars, addressbar, etc). Just the html contents of the webpage, and nothing else. I want to be able to do this within linux from the terminal. I also have to do it in such a way that it works across multiple linux machines running the same version of firefox. So this removes any possibility of using a profile. I was hoping there would be a simple parameter to firefox that would allow me to turn these settings off. I dont believe there is.
The only possibility I have found is through javascript's window.open. It appears the parameter specs to window.open arent even functioning in firefox 1.5.0.9. I have read that some of them were removed in firefox 3.0+, but have not found anything regarding the version I am using, 1.5.0.9.
This is what I am using to open my .html file using windows.open...
test.html:
<html>
<body>
<script>
window.open('./rel_notes.html','_self','toolbar=no,menubar=no')
</script>
</body>
</html>
And then just running 'firefox test.html' from the terminal.
Both the toolbar and menubar still appear when I do this. What am I doing wrong? Is there a easier way to do this?
If your browser settings allow pop-ups without notifications from X source (localhost i presume?) then the following might work:
window.open('./rel_notes.html',null,'menubar=no,toolbar=no');
window.open('','_self',''); //this is needed to prevent IE from asking about closing the window.
setTimeout('self.close();',500);
Taken from a link in the link bungdito gave me:
After a window is opened, JavaScript can't be used to change the features.
So by opening test.html, and then using window.open on _self, I am trying to adjust features to a window that has already been opened, using javascript.
Source: https://developer.mozilla.org/en-US/docs/DOM/window.open
I create a secondary browser window with Javascript code, using the window.open function, and fill it programmatically with some HTML content. It works well for all browsers that my application supports except for one: Safari on Mac. In fact, the window itself is OK but the print command is disabled. Does anybody have an idea why? I should mention that the main reason to show this window is to allow the users to print some data. I guess I could implement a "Print" button in the page but I would prefer not to (and it may not work either, but I haven't tried it).
Here is a simplified example of the code that I use to create the HTML content:
var pp = window.open("", "_blank");
pp.document.writeln("<html>");
pp.document.writeln("<head>");
pp.document.writeln("<title>");
pp.document.writeln("Hello");
pp.document.writeln("</title>");
pp.document.writeln("</head>");
pp.document.writeln("<body>");
pp.document.writeln("The body");
pp.document.writeln("</html>");
pp.document.close();
I tried variations around that code, without any success. My tests are done with Safari 5.1 on Mac OS X 10.6.8. Any help is welcome!
Have the window print itself:
Before your </html> add:
pp.document.writeln("<script type='text/javascript'>window.print()</script>");