MSIE window.open not opening - javascript

So I'm having a popup that opens upon click on a link, but IE (8.0) doesnt want to show it.
Send page
And this function in JS:
function tellafriend(url) {
popup = window.open(url, "Send page", "width=500,height=600,scrollbars=yes,resizable=yes");
popup.focus();
}
IE tells me the error is at the line popup = window.open...
Any ideas on how to fix it?

I can't tell you why this happens, but IE doesn't let you have a space in the second parameter of window.open. If you change it to
popup = window.open(url, "Sendpage", "width=500,height=600,scrollbars=yes,resizable=yes");
the window will pop up.

Related

Javascript opens duplicate tabs in Firefox

I have the following link that when clicked, opens a new tab and refreshes the page with the link in.
It works fine in Safari and Chrome but opens duplicate tabs in Firefox.
Run Letters
function openWindowReload(link) {
var href = link.href;
window.open(href,'_blank');
location.href = 'index.php' + "?welcome_letters=export&welcome_letters=export"
}
Any ideas why Firefox is doing this and how to resolve it?
I think it's because you don't stop the default behavior.
Could you call preventDefault on the click event?

Opening an alert outside of the popup window in a Chrome Extension

I have a Chrome extension I am writing where I have a button on the popup page, that when pressed should open an alert with a little help text for the user. I can get the alert to appear in the popup window by calling:
var button = document.getElementById("HelpMe");
button.addEvenListener("click", function(){
alert("HelpText");
});
But this opens the alert in the popup window, which puts it mostly offscreen. I want to make the alert appear in the main tab, which would put the alert right in the center of the screen.
I tried this:
var button = document.getElementById("HelpMe");
button.addEventListener("click", function(){
chrome.tabs.executeScript(null, {
code:`
alert("HelpText");
`
});
});
But it didn't seem to do anything, and I can't get any error messages or logs to appear that I have been able to find. Advice is appreciated.

Javascript popup window in background after userinteract

I want to open a little popup after clicking on a button.This Popup should open in the background.
This is my Code
document.getElementById('btn').addEventListener('click', function() {
var newWindow = $this.open('/popup',"MyTitle", "width=600,height=400,scrollbars=yes,resizable=yes,location=no");
newWindow.blur();
this.window.focus();
}, false);
What is my mistake? Why does it not open in the background?
Have you tried window.focus(); instead of this.window.focus(); ? I'm unsure if this will work as most browsers it causes security issues. Popunders aren't popular!

Can i Call Window.open from confirm dialog Box?

Can I call window.open from confirm dialog box using javascript?
My Requirement:
In case browser pop up blocker was enabled means ,i want to open pop up window using window.open(); but it was not happening so that i have to show the confirmation message which is "Browser popup blocker was enabled, now pop up has been open". now i click 'OK', on that time i want to call window.open() function.
<html>
<body onload="openPopup();">
<head>
onload Popup Window
</head>
</body>
<script>
function openPopup () {
var href= 'http://google.com';
popUp = window.open(href, "_blank");
if (popUp === null || typeof popUp === 'undefined') {
var ret = confirm("this alert is displayed by Blocker, Continue to Open ?");
if(ret){
window.open(href,"_new");
}
} else {
popUp.focus();
}
}
</script>
Is it possible or is there any other way to handle this scenario?
No.
Pop-ups are generally only allowed following a user's click, and as you've already seen in your code onload usually won't allow it.
However, you could use your own UI, to create a custom confirmation box that the user can click on to open the pop-up. This will work, unless the browser's pop-up blocker is overzealous enough to block even click-to-open popups without prior confirmation within the browser itself.

unable to close tab after log-out in firefox

i tired to find out way to close tab after log out in Firefox.
<script type='text/javascript'>
window.open('','_self');
window.close();
document.execCommand('ClearAuthenticationCache');
</script>
working in other browser but problem in Firefox. i need to close tab when signout/logout attempt.
Firefox will not allow you to close windows or tabs that a user opened.
Most financial sites for this reason will ask users to click a button and open a new window.
you can do this with window.open. Store the handle returned by that and use it to close the window you opened. The user may have many other tabs open in that window.
Refer: window.close
This is how you close a window that you open.
var openedWindow;
function openWindow()
{
openedWindow = window.open('moreinfo.htm');
}
function closeOpenedWindow()
{
openedWindow.close();
}

Categories