Remove meta tag refresh
Removing the meta tag isn't an option, based on the link Robert Rozas added --> Using Javascript to override or disable meta refresh tag
Since I don't have your code I can't help completely, but below is a way to auto refresh the page on load & then stop refreshing it on an event.
Clicking on the Test Button will stop the refresh.. just hook this into your event and it should solve your problem -->
<script>
$(document).ready(function () {
$("#test").click(function (e) {
// This event will clear the timeout
clearTimeout(timeout);
});
var timeout = setTimeout(function()
{
// The refresh is occurring here
location.reload();
}, 4000);
});
</script>
<button id="test">Test</button>
The following will remove the meta tag (quotes removed)
$('meta[http-equiv=refresh]').remove();
Is it possible to disable meta refresh in Google Chrome?
I was looking for the same kind of extension (Spanish online newspapers abuse of the meta/refresh tag), I found none, and, among other sites, I landed in this question.
So I started to analyze how this could be done. It was not simple, and needed some tricks, but I've done it.
The extension is already in Chrome Web Store, "Stop Autorefresh": https://chrome.google.com/webstore/detail/lcldcllmbokpbniijpnkpgoboadbfphb
More info, mostly in Spanish, in http://gallir.wordpress.com/2012/07/12/stop-autorefresh-evitar-la-recarga-automatica-tipica-de-los-periodicos-digitales-en-chromechromium/
From the extension description:
Implementation notes: Chrome and Chromium don't allow to disable the refresh meta tag, nor they provide an easy method for cancelling it. The extension uses a http trick. When the [unavoidable] refresh is fired, it intercepts it, checks if it's the refresh event, if so, it redirects the connection to a small script (currently en App Engine). This script just returns a 204 http status code, so the browser does not modify the content of the page, and doesn't try to refresh it again.
Meta refresh tag not redirecting with noscript tags
The error cause by the quote. Try change it to:
<?php
echo "<noscript>
<meta http-equiv='refresh' content='0; url=http://mysite.tld/javascript-disabled.html' />
</noscript>";
?>
But i'm dought if this will work.
A diffrent approach will be to create a non-javascript page and use javascript to redirect. Something like:
window.location.assign("jsenable.html")
Good luck!
Disable HTML auto-refresh?
Assuming you are using a UIWebView to display the site, you could use [webView stringByEvaluatingJavaScriptFromString:@"..."];
, where "..." is this javascript:
var metaTags = document.getElementsByTagName("META");
for(var i = 0; i < metaTags.length; i++) {
if (metaTags[i].getAttribute("HTTP-EQUIV").match(/^REFRESH$/i))
metaTags[i].parentNode.removeChild(metaTags[i]);
}
Condensed down to one line for convenience:
var metaTags = document.getElementsByTagName("META"); for(var i = 0; i < metaTags.length; i++) { if (metaTags[i].getAttribute("HTTP-EQUIV").match(/^REFRESH$/i)) { metaTags[i].parentNode.removeChild(metaTags[i]);}}
Edit: Well...after all that, turns out it's not possible to cancel an existing refresh request by simply removing the meta tag from the document. Once the parser sees the meta tag, it will refresh regardless of any javascript trickery you do. Unfortunately, the only way to overcome this is to modify the HTML page directly.
meta refresh redirect to top frame
Javascript won't work in the refresh meta tag like that.
As you're using javascript anyway, keep it simple like this:
<script type="text/javascript">
window.top.location = 'http://domain.tld/whatever/';
</script>
But there's also a better (because smarter) way to do it. This doesn't require you to hard-code the URL for each page. It checks if the page is topmost and if not, if calls the page's URL to the top:
<script type="text/javascript">
if(window.top.location != window.location)
{
window.top.location.href = window.location.href;
}
</script>
And if you would prefer to completely avoid using javascript (which some users will have disabled), there's also an even simpler way to do it. Add the following to your head section and all links on that page will open "topmost":
<base target="_top">
All you have to do is to choose one of these three options. All of them should get you going just fine.
Related Topics
Jquery Click Event Not Firing on the Element Created Dynamically Using Jquery
Twitter's Typeahead.Js Suggestions Are Not Styled (Have No Border, Transparent Background, etc.)
React Native Flexbox - How to Do Percentages || Columns || Responsive || Grid etc
Jquery UI Switchclass() Method Is Not Working Properly
Custom Cursor Interaction Point - CSS/Jquery
Javascript: Change CSS File Dynamically + Cookie
Using JavaScript Calculated Values in Less
Update Three.Js Raycaster After CSS Tranformation
Position Fixed - Horizontal Scroll
Why Aren't Safari or Firefox Able to Process Audio Data from Mediaelementsource
How to Automatically Close Alerts Using Twitter Bootstrap
Select Element by CSS Style (All with Given Style)
Very Simple JavaScript/Jquery Example: Unexpected Evaluation Order of Instructions
Google Chrome Customize Developer Tools Theme/Color Schema
Overlay Play Button Over Video