My Code:-
<BODY onload="redireccionar();">
<SCRIPT LANGUAGE="JavaScript">
function redireccionar() {
setTimeout("self.close()", 500);
}
</SCRIPT>
Above is my code regarding facing issues on chrome and firefox while it works fine with IE. I have tried almost all functions available here but still facing the same.
please suggest any solution. Thanks in advance.
I searched everywhere and found out that you have to trick the browser into thinking it was opened w/JavaScript. This worked for me in Firefox and IE:
Close this window
Related
I was trying to use Visibility API, but it is not working for a child. The minimal example to reproduce:
<script>
document.onvisibilitychange = () => {
console.log(document.visibilityState);
}
if (!window.opener) {
window.open(window.location.href, '_blank');
}
</script>
After that, the parent window still prints "visible"-"hidden", but child prints "hidden" once only on refresh.
It works fine in the latest Opera browser, but not in the Chrome
To be honest, when I came to this minimal reproduce, I'm stuck and have no idea where to dig. Any ideas what could be wrong?
I also stumbled over this issue. I think that this bug was introduced in Chrome 84. I testet it with version 83 and it worked as expected. The current Canary-Build (Version 86) is also working.
It is working good in internet exlporer but in chrome it works only if the user clicks on somewhere in the page i.e., works only when the user gives a click on that page at least once before pressing browsers back button. I want to make it work as same as in internet explorer.
here is my code:
<html>
<head>
<script>history.pushState(null,null,location.href);
window.onpopstate=function()
{
history.go(1);
}
</script>
<body>
<a location.href="home.php" rel="index,follow"></a>
</body>
</html>
I've stumbled on this question quite a lot and I had to achive the same thing
might not be the best solution, but I've made it to work in browsers IE, Explorer, Chrome, did not test Firefox tho, with this code:
<script type = "text/javascript" >
history.pushState(null, null, location.href);
history.back();
history.forward();
window.onpopstate = function () {
history.go(1);
};
</script>
The problem with Chrome is that it doesn't trigger onpopstate event unless you make browser action ( i.e. call history.back). Thats why I've added those to script. After adding only that made it work in Chrome but other browsers stopped adding history.forward fixed it and started to work on every browser mentioned.
Source if you want to know more or at least what helped me solve this
Hope it helps!
The code i used in the javascript to close the window is as follows
window.open('','_self','');
window.close();
in jsp
Close
it's not working in chrome version 36.0.1985.143, it worked in previous chrome version, IE and in FF also. How can i fix it.
Please help me.
Thanks in advance.
The chrome latest release has changed that functionlity as there has been several security issues because of that. You need to try like this:
chrome.windows.remove(integer windowId, function callback)
You can check here
I have seen many examples on using javascript to resize a browser window, but for me they all fail to perform that function in IE. I include my code to see if anything is wrong with it that I just don't see. The code works great in FF but that is not used at my location.
I am no javaScript expert, but I am no slouch either. If I were new to javaScript I would be hating it. I'm sure it has something to do with IE but I cannot explain it.
Any help would be great.
CODE:
//window.sizeToContent();
window.resizeTo(700, 700);
I read in the docs that sizeToContent will not work in IE but resize should. It is an incredibly simple statement.
This works for me in Internet explorer 8
<html>
<head>
</head>
<body>
<h1>Resized</h1>
<script>
window.resizeTo(400,400);
</script>
</body>
I did some testing in IE9 beta (that's the only version of IE that I have on this machine), and it seems that window.resizeTo does not work on the initial page load. It does work if you refresh the page. Also, it does work if you delay its execution:
setTimeout(function() {
window.resizeTo(200, 200);
}, 2000);
(at least in IE9 beta)
The "working" example with IE is working only because there are no more tabs on the window.
If the windows has other tabs loaded, then it DOES NOT work. It's a security measure of IE8 and higher.
If you need to resize your window, you will need to open a new window. And for that, you will need to make the user click a button with the window.open onclick event, otherwise any popup blocker will block it.
You won't be able to resize the window reliably with JavaScript. It's not possible in IE 7 with tabbed browsing enabled. It's also potentially annoying for the user.
This seems to be IE only.
If your window is a "dialog" like:
window.showModalDialog(url,...)
I found this hacky way to make it the right size:
<script type="text/javascript">
//window.resizeTo(1000, 790); //Will not work if its a dialog
window.dialogWidth = '1000px';
window.dialogHeight = '790px';
</script>
I have a problem using $.getScript() on chrome. It doesn't work on chrome browser. I've tested it on firefox, ie and safari and it worked. All I have on my external script is an alert() and it doesn't work.
Here's the code:
page
$(document).ready(function(){
$("#btnGet").click(function(){
$.getScript("script.js");
});
});
script.js
alert('Get script loading');
Is anyone have experienced this problem?
Thanks guys for making it clear to me.
I think I would have my script inline instead since the inline code will work fine on all browsers.