简体   繁体   中英

Refresh a page on load for IE only

I am using a jquery plugin, that has problems on Internet Explorer. The plugin works, but only when the page has been refreshed.

I want to use Javascript to refresh the page on load, but I only want the script to run IE and not in any other browsers.

There is a script here , which can be used to make the page refresh on load. However, the script is for all browsers. How can I limit it to just Internet Explorer?

Also, on the example page, the script is run directly from the HTML page. Is there away I can link to it (eg so I can serve the script in a separate .js file)

As I said in my comment

You do not want to reload the page to make a plugin work in IE - you want to fix your page so it works in IE without the reload. Why do you not show us the page and perhaps we can fix it without the reload?

If you insist do this

<!--[if IE]>
<script>
window.onload=function() {
  if (location.href.indexOf('again')==-1) location.replace(location.href+'?again');
}
</script>
<![endif]-->

sometimes mplungjan's answer is the best way,
sometimes the best way is:

if (navigator.appName=="Microsoft Internet Explorer")
{ // your code
} else { // your code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM