I am facing an issue:
I need to do html meta refresh (because I do windows gadget, this is only thing what works in Internet Viewer (not Internet Explorer), there is no location.href or anything similar (it always opens in new windows instead of currect gadget windows).
Therefore onhly HTML meta refresh works to link a page.
So I was tweaking the JS to have a variable into the meta refresh, and it works only in chrome, but it doesnt work in ordinary Internet Explorer... once I make it work in IE, it shall work in gadget windows too.
How to adapt this code to work on Internet Explorer (if you have a chance to try it out in Internet Viewer, would be even better).
<html>
<head>
</head>
<body>
<meta http-equiv="refresh" content="5;url=http://www.google.com">
<script>
var username = "jzaloudek";
var url = "http://localhost/excel/test.php?name=" + username;
var time = 5;
document.getElementsByTagName("META")[0].httpEquiv = "refresh";
document.getElementsByTagName("META")[0].content = time + ";url=" + url;
</script>
<p>Loading...</p>
</body>
</html>
Related
In our software, we have a page with a link that opens a page within the same site in a new tab using target='_blank'. When the user is done working on that newly opened page, they click a button and when the page refreshes, it calls the following code.
window.opener.location.href = window.opener.location.href; window.close();
This has worked fine for ages but within the last week or so stopped working in all browsers. I can't seem to find anything when I google it about a new security restriction being implemented that would cause this. Any idea what's going on and how to get it working again? I've tested the following code in chrome, firefox, edge and IE11. In all but IE11 window.opener is null. In IE it is not. Is there possibly a new security setting in browsers that would cause this?
<html>
<body>
click me
</body>
</html>
<html>
<body>
<script>
alert(window.opener === null);
</script>
</body>
</html>
I am not sure which version of chrome browser you tested your code on. To avoid "tab-napping" attacks, many browsers have started implementing noopener behavior by default for anchors that target _blank.
Chrome enabled noopener behavior in release 88.
Safari also enabled this in release 68.
I couldn't find any reference to IE 11 change. But it's worth trying adding rel="opener" in anchor tags with target=_blank
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!
With window.history.pushState it is possible to push a state to the browser's history.
Example:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<input type="button" value="foo" onclick="setHistory('foo');">
<input type="button" value="bar" onclick="setHistory('bar');">
<script>
function setHistory(string) {
document.title = string;
window.history.pushState(
'object or string',
'',
string+'.html'
);
}
</script>
</body>
</html>
After clicking on the foo and bar button the responding entries will appear in the browser's history. This works in Firefox, Chrome, and Safari. However, not in IE (>10) and Edge even though they officially support it. Is there a way to achieve this?
The answers at Does Internet Explorer support pushState and replaceState? are not useful since they explain the problem only with IE<10 where pushState is not supported.
Edit
Apart from not updating the history, pushState seems works otherwise fine in IE and Edge, i.e. updates the URL, can navigate back and forth, the "back and forth drop down list" is updated accordingly.
Edit 2
I just read https://msdn.microsoft.com/en-us/library/ms535864(v=vs.85).aspx. Under "Remarks" it states
"For security reasons, the history object does not expose the actual URLs in the browser history."
So maybe the part of pushState I am after just isn't supported in IE and Edge?
IE10 and above do support pushState and replaceState and your example code works in both.
However you might be triggering compatibility mode and rendering using a lower version of IE. (Again your sample code does so and renders using IE7 which doesn't support history api)
You can check this by pressing F12 to bring up the developer tools and seeing what version of IE is listed on the right of the black bar.
To stop it doing that, add this to your <head>:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
IE/Edge seems not to play along for some reason - not surprising I guess.
The only way to change the history seems to be an added reload of the page via window.location.reload(), history.go(0), or window.location.href=window.location.href.
https://codepen.io/pen seems to do it that way.
This is a bit annoying since one would also like to keep the current state of the website. Maybe one could check whether the users browser is IE and only then do annoying reload. Other browsers seem to play along just fine.
We have a custom session mechanism in our application, that allows user to have different session (e.g., different credentials) in each browser tab, even if URLs are the same. This mechanism works great in all major browsers including IE (v11).
The problem
We want to supply each browser tab with different favicon (with different color) to indicate which tab belongs to which session. To do that, we set different favicon URL depending on session using
<link rel='icon' href='url_to_favicon_session_id' type='image/ico'/>
It works great in Firefox and Chrome, however IE seems to share favicon between all tabs pointing at the same URL (icon is the same in each tab, order of loading determinates favicon visible in each tab).
The question
Can we force IE somehow to not share favicons across browser tabs with the same URLs?
Note, changing URL is not an option here.
Minimal Working Example
Below full code snippet to reproduce problem (put it on a webserver to run in IE with HTML5 support; Open this file in many tabs of the same browser).
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script type="text/javascript">
var icons = [
"http://google.com/images/google_favicon_128.png",
"https://assets-cdn.github.com/favicon.ico",
"https://www.microsoft.com/favicon.ico?v2",
"https://s.yimg.com/rz/l/favicon.ico",
"http://www.stackoverflow.com/favicon.ico",
];
var idx = localStorage["favicon"];
if (idx === undefined) {
idx = 0;
} else {
idx = parseInt(idx);
}
localStorage["favicon"] = (idx + 1) % icons.length;
var link = document.createElement('link');
link.type = 'image/x-icon';
link.rel = 'icon';
link.href = icons[idx];
document.getElementsByTagName('head')[0].appendChild(link);
</script>
</head>
<body>
Open this page in multiple tabs. Favicon should be different in each tab.
</body>
</html>
In my experience, IE, along with almost all other browsers, uses a cache mechanism separate from the cache of the page to prevent constant retrieval of favicons. This means that changes to the favicon can be unpredictable unless the url is changed and the cache for the domain cleared. The only reliable way I can see around this is to add a unique id to identify the tab for each session forcing IE to cache each sessions's icon separately.
You can try a GET variable (i.e. yoursite.com/page?sessionid), however, in my experience, IE still cache's the favicon across page in the same domain regardless of GET variable. In fact, Microsoft's documentation says that you can use the link tag to get different pages to have different favicon's, however, I often find that IE's favicon cache won't update even if you change the link tag without clearing the cache. Also, IE won't display a favicon at all if you have all caching turned off. And, it appears that in some versions of IE, the link tag doesn't take precedence over whatever favicon is at the default location either.
I have had some success with using a routing script to get requests to the right page and then appending the sessionid as part of the path (ie. yoursite.com/page/sessionid), however. This requires a bit of extra work in your routing script to ignore the sessionid but it is the only thing, in my experience, that worked simi-reliably to get IE to recognize different favicon's for different sessions.
Microsoft IE8 and IE9 used to offer functionality to start
a WebDAV explorer on a Windows computer from within a WebPage:
<HTML>
<HEAD>
<SCRIPT>
function fnDavStart(oSpanObj, sPath) {
oSpanObj.navigateFrame(sPath, "_blank");
}
</SCRIPT>
</HEAD>
<body>
<div ID=davDiv>
<SPAN ID=oWebDavHelper style="behavior:url('#default#httpFolder');" onclick = "fnDavStart this, 'https://webdav.myserver.com')">
Click here for WebDAV folder
</SPAN>
</div>
Now the method navigateFrame() and/or the behaviour "httpFolder" seems to be gone in IE11.
How to get similar functionality in IE11?
Thanks,
You can force IE to render like IE9 with this code in your meta tag:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
It will make all IE versions (even the ones not yet released) to render pages and javascrit like IE9.
I havent used the behaviour approach before, but have you checked if the SharePoint OpenDocuments object still works?
Open Now
Here's some code with the js embedded in java.
https://github.com/miltonio/milton2/blob/master/milton-server-ce/src/main/java/io/milton/http/fs/FsDirectoryResource.java