This is some js in one of my views:
var $link = 'info';
I want to pop open a new small window when someone clicks on the details of an item on my page. The code above renders this html on the page:
info
which is only working in chrome (no popup blockers are enabled in IE9 or FF ) what am i doing wrong here?
EDIT
ok ive updated the markup same issue only works in chrome,
info
EDIT #2
Ok think ive got the markup kinda fixed FF and IE are now opening my popup but when they do the parnt window content is replaced with [object] in IE and [Window Object] in FF.... Now what the heck is going on?
info
Probably because you are not escaping double quotes.
Modified:
info
ok so this article pointed me to my solution. Popup errors Object Window
Here is my new markup:
var $link='info';
Here is how it renders:
info
And it works perfect in all 3 browsers.
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 a close link on my web page. I would like to function it to close the current tab when click it. I have written
close
The above code seems to be working well in Internet Explorer. But it is not working in Mozilla Firefox and Google Chrome. Please help me to resolve this.
You can only close windows/tabs that you create yourself. That is, you cannot programmatically close a window/tab that the user creates.
For example, if you create a window with window.open() you can close it with window.close().
As of Chrome 46, a simple onclick=window.close() does the trick. This only closes the tab, and not the entire browser, if multiple tabs are opened.
You can use below JavaScript.
window.open('','_self').close();
In a HTML you can use below code
close
I have tried this in Chrome 61 and IE11 it is working fine.
But this is not working with Firefox 57.
In Firefox we can only close, windows which opened using below command.
window.open()
Found a one-liner that works in Chrome 66 from: http://www.yournewdesigner.com/css-experiments/javascript-window-close-firefox.html
TLDR: tricks the browser into believing JavaScirpt opened the current tab/window
window.open('', '_parent', '').close();
So for completeness
<input type="button" name="close" value="close" onclick="window.close();">
Though let it also be noted that readers may want to place this into a function that fingerprints which browsers require such trickery, because Firefox 59 doesn't work with the above.
Try this:
window.open('', '_self').close();
Try this:
<script>
var myWindow = window.open("ANYURL", "MyWindowName", "width=700,height=700");
this.window.close();
</script>
This worked for me in some cases in Google Chrome 50. It does not seem to work when put inside a javascript function, though.
Use this:
window.open('', '_self');
This only works in chrome; it is a bug.
It will be fixed in the future, so use this hacky solution with this in mind.
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>");
I use :
Window.showModalDialog(...)
to open a dialog window,
I want show some HTML code in this window, but I don't have a file. (Can't use URL to visit)
like show "hello world!" in this dialog window.
Can I do it?
Interesting question!
I'm not an expert in modal dialogs, but I don't think you can, because it's in the nature of a modal dialog to block any further code from being executed until the window is closed again.
I thought about using a data: URI that you could use as the first argument to showModalDialog instead of a normal URL:
window.showModalDialog("data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D" ....);
but according to the MSDN page on data: URIs, that will not be supported in Internet Explorer. (see the "Remarks" section on the linked page)
It might work in Firefox, though: More on data URIs at Mozilla Developer Central
Update: It works in Firefox: JSFiddle but, as expected, not in IE. You only get a blank window there.
Good question and answer. (+1)
I just thought I'd add, that if you do need to enter HTML into a modal dialog, you may want to look into using a Javascript library to accomplish it. I've used Dojo's "dijit.Dialog" several times with HTML, including images, form controls etc... You can style it however you like, and it works well cross-browser.
You can check out a few example of dijit.Dialog's use over at DojoCampus.
Cheers.
So I've got a bookmarklet which should open up a page in a new window.
javascript:window.open('http://timetableapp.com/TimeTable/bookmarklet/index.html','TimeTable%20Timer','status=no,directories=no,location=no,resizable=no,menubar=no,width=400,height=210,toolbar=no');
The code works perfectly in Safari, Firefox, and Chrome; but as expected IE (7 and 8) is causing problems. IE gives me a useless error when I open the bookmarklet, and no window opens.
I've tried to editing the bookmarklet so that it appends the page with a script tag. Then inside the script tag the window.open() code is added, or it accesses the script (which contains the window.open() ) [I've tried it both ways]
I'm at a loss now.
Anyone have any idea how to get the page to popup in IE (preferably with code that works in Safari, FF, and Chrome too)?
Thanks,
EDIT:
The final code I ended up with:
javascript:(function(){ window.open('http://timetableapp.com/TimeTable/bookmarklet/index.html','TimeTableTimer','status=no,directories=no,location=no,resizable=no,menubar=no,width=400,height=210,toolbar=no'); })();
You can't have %20 or spaces in your window name. The name is for referring to the window again later in code.
Try:
javascript:window.open('http://timetableapp.com/TimeTable/bookmarklet/index.html','TimeTableTimer','status=no,directories=no,location=no,resizable=no,menubar=no,width=400,height=210,toolbar=no');