I want to change the value “href” in my html page if someone opens it using IE.
At first I tried with the button, but the final goal is without it.
This is what I have:
<script type="text/javascript">
function myFunction()
{
var oldHTML = document.getElementById('troca').href="http://player.vimeo.com/video/39640718?title=0&byline=0&portrait=0"
var newHTML = document.getElementById('troca').href="http://www.youtube.com/embed/VwjI7ICgcJ0?rel=0";
if (navigator.appName!='Microsoft Internet Explorer')
{
**//what action i have to put in here?**
}
document.getElementById("troca").innerHTML=x;
}
</script>
</head>
<body>
<p>clique, se for internet explorer nao vai trocar nada!</p>
<button onclick="myFunction()">Troca</button>
<br/><br/>
<iframe id="troca" src="http://player.vimeo.com/video/39640718?title=0&byline=0&portrait=0" width="910" height="512" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</body>
Does someone know what I have to put in there for my code changes?
You can use conditional comments if you don’t want to use JS:
Here’s a fiddle and another link about IE conditional comment syntax.