0

Is there a way with javascript to replace an iframe, for example

<iframe id="myframe"></iframe>

with a link like this...

<a href="">go here</a>

only if browser detects IE9? If I write a pure javascript code from my <head></head> area. I want this action to occur before the iframe is fully loaded onto the page.

klewis
  • 7,459
  • 15
  • 58
  • 102

1 Answers1

1

You can use conditional comments to target IE 9 and write a script to change out the iframe. Or you can try to use the conditional comment to select which tag gets displayed directly.

<!--[if IE 9]>
<a href="">go here</a>
<![endif]-->
<!--[if !IE]> -->
<iframe id="myframe"></iframe>
<!-- <![endif]-->
  • thats half the solution for me. thank YOU Austin. I figured out how to remove the element, but how do I replace it with an anchor link with pure javascript?l – klewis Feb 06 '15 at 21:03
  • can i put that IE9 tag inside the body? or does it only work in the head? – klewis Feb 06 '15 at 21:45
  • In the article I link to they use an example if it in the body. I'll update my answer with something for you to try –  Feb 06 '15 at 21:46