ie6下iframe中里使用target="_top" 链接失效

ie6 bug target="_top" 不起作用(原因是跨域,ie6会更加严格,当都添加可信任站点时问题解决。)

html

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">
<html>
    <body>
        <iframe src="http://bemmu4.appspot.com/static/iframe.html"/>
    </body>
</html>

iframe

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">
<html>
    <body>
        <a href="http://www.google.com" target="_top">Let's go to Google!</a>
    </body>
</html>

解决方法:

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">
<html>
    <body>
        <a href="http://www.google.com" target="_top" onclick="javascript:if(window.top){window.top.location='http://www.google.com';}">Let's go to Google!</a>
    </body>
</html>

 

posted @ 2010-12-27 16:24  chesihui  阅读(1100)  评论(0编辑  收藏  举报