This is kind of strange issue i am facing, below is my simple code
<script type="text/javascript">
function openMyWindow() {
var formid=document.getElementById('myForm');
window.open('https://test.com','POPUPWINDO','left=443,top=107,width=650,height=650,location=0,toolbar=0,statusbar=0,menubar=0,scrollbars=0,resizable=0');
formid.method = 'post';
formid.target = 'myWindow';
formid.action = 'https://test.com';
formid.submit()
}
this is working in my local ie11 and chrome. Server chrome it is working however IE11 it is not working. Tried almost everything . I debugged this code using ie debugger found that one window opens at window.open and another Tab opens at submit()
Related
I am trying to send data to a popup window which opens by clicking a button.
All my code is in php where I include javascript and html, I will just show html and js here.
Consider my popup window (say, popupwindow.html) code as just
<div id = 'getData'></div>
Now on the page(say, main.js) where I put the button clicking which the popup opens, I am computing some data and trying to send it to popupwindow.html.
Here is relevant main.js code that gets executed after clicking the button
var popup = window.open("popupwindow.html", "popup", extraParams); //ignore extraParams
$(popup).on('load', function() {
//console.log("inside onload function");
popup.document.getElementById("getData").innerHTML = data; //here data is some string
});
Now this code works perfectly on Chrome and Firefox, but in IE load() function does not get executed. I know this because the console.log line when uncommented, does not print on the console. Tried versions of jQuery from 1.2.3 to 2.2.1 where the code runs successfully on Chrome and Firefox(but not in IE)
Note: I cannot execute the required code on popup page(popupwindow.html) because of some constraints. I have to write it on main.js and send it to popup.
I saw all other questions which said onload() or similar function in IE gives problems but I still could not find the appropriate solution. Please let me know how I can fix this for IE.
I am developing an application with ASP.net and VB.net. In that application i have written this simple javascript function in the popup window in order to refresh the parent window when the popup is closed.
function RefreshParent() {
if (window.opener != null && !window.opener.closed) {
window.opener.location.reload();
}
}
window.onbeforeunload = RefreshParent;
This was working fine. But suddenly it stopped working. Its still working on Firefox and internet explorer.
its not just a problem in my PC. I am getting this problem from every user who is using chrome to access the application.
The function was working fine. Its just stopped working suddenly. And I can assure that there was no such changes been made which might cause this happen. Its still working on Firefox and IE
But i Have tried the following to see if the problem is related with chrome settings
to see if the javascript is enable or not I double checked the content settings section in advance setting of the browser. Allow all site to run Javascript option is selected.
And I have also re installed chrome.
According to the suggestion of Jeremy I have added two alerts in the javascript function to see if the function is accessed or not.
function RefreshParent() {
alert("Accessed the function!");
if (window.opener != null && !window.opener.closed) {
window.opener.location.reload();
}
}
alert("refreshed parent window!");
window.onbeforeunload = RefreshParent;
I can only see the 2nd alert. But this alert comes when i click to open the popup.
Also when I add this two alert the refreshing function also stops working in firefox (I did not checked in ie with the alert on.)
How to solve the problem
The following solution works for me. In POPUP.vb.aspx POPUP page I added the following line of code under button click
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "refresh", "var url = window.opener.location.href; window.opener.location.href = url;", True)
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "CloseWindowScript", "window.close();", True)
I still have the javascript function ( mentioned in the question) in the asp.net page. Its not clear why its suddenly just stopped working in Chrome.
The following code works fine in Firefox but not in chrome (In chrome it only opens the first item)
It's supposed to open all checked links in a new tab. Any suggestions?
jQuery(document).ready(function(){
jQuery("#open_in_new_tab").click(function(){
jQuery("#sales_order_grid_table input:checked").each(function(index){
var $href=jQuery(this).parent().parent().attr("title");
window.open($href);
});
});
});
I need to open an url in a pop up window, in the background. Currently in my code, the new windows pops up on top of the current window, without going in the background. I am running my code on firefox 23.0.1-fedora 18.
I have tried using .blur() and .focus() js methods, but they are not working.
Is there a clean and reliable solution for this, which will work for firefox and chrome?
http://jsfiddle.net/6La9W/1/
html
<button >click me</button>
js
$("button").click(function(){
var sOptions = 'target=_blank,toolbar=no,scrollbars=yes,location=yes,statusbar=yes,menubar=no,resizable=1';
var popup = window.open('http://www.stackoverflow.com','',sOptions);
popup.blur();
});
Browsers don't allow this nowadays because peoples open illegal things in behind popup, and you shouldn't do this. but still you can do this and it is worked in IE only.
$("button").click(function(){
var sOptions = 'target=_blank,toolbar=no,scrollbars=yes,location=yes,statusbar=yes,menubar=no,resizable=1';
var popup = window.open('http://www.stackoverflow.com','',sOptions);
window.focus();
});
I can't seem to figure out why the following simple popup will not work in IE9. FF & Chrome popup as expected, but IE does not appear to do anything when the link is clicked. I tried the IE9 debugger, but didn't get any helpful information out of it.
In the head section:
<script type="text/javascript" language="JavaScript">
function JSPopup(linkref) {
window.open(linkref,"Report Definitions","width=600,height=480");
return false;
}
In the body:
<strong>Report Definitions</strong>
Thanks for your help,
Filip
Turns out the problem was the name given to the popup - IE doesn't allow spaces, FF & Chrome do:
window.open(linkref,"Report Definitions","width=600,height=480");
needed to be changed to:
window.open(linkref,"ReportDefinitions","width=600,height=480");
This works across browsers.
Filip
This is part of the security changes made in IE6. Now you can only call "window.open" from within a user-initiated event. For example, your code would work inside an element's onclick event. The "window.open" http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx MSDN page says this:
"This method must use a user-initiated action, such as clicking on a link or tabbing to a link and pressing enter, to open a pop-up window. The Pop-up Blocker feature in Internet Explorer 6 blocks windows that are opened without being initiated by the user."
Example...
function popUpWin(url,wtitle,wprop){
if (!window.open){ return; } // checking if we can't do this basic function
// Kill if(win), since win was a local var this was a usless check
var win = window.open(url,wtitle,wprop);
// next line important in case you open multiple with the same 'wtitle'
// to make sure the window is reused and refocused.
if (win && win.focus){ win.focus(); }
return false;
}