Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ie8 FF inserting-a-comment-in-innerhtml error #17

Closed
hyingzi opened this issue Dec 23, 2015 · 5 comments
Closed

ie8 FF inserting-a-comment-in-innerhtml error #17

hyingzi opened this issue Dec 23, 2015 · 5 comments

Comments

@hyingzi
Copy link

hyingzi commented Dec 23, 2015

http://stackoverflow.com/questions/15006001/inserting-a-comment-in-innerhtml

@emn178
Copy link
Owner

emn178 commented Dec 23, 2015

sorry, I don't understand.

@hyingzi
Copy link
Author

hyingzi commented Dec 30, 2015

刚看到您是台湾的,那我打中文。。。英文不好~
因为插件是抓取注释里的图片激活加载的,如下

<div class="lazyload">
  <!--
    <img src="image.png" />
  -->
</div>

在有些场景(ajax、模板等)使用中,需要动态的去插入这些代码,如

var tpl = '<div class="lazyload"><!--<img src="image.png" />--></div>'

// 写入
document.getElementsByTagName("body")[0].innerHTML = tpl
$(".lazyload").lazyload()

这个的时候,在ie8或者某些firefox版本中,写入的其实是

<div class="lazyload"></div>

也就是说,注释里的内容被过滤掉了……

还有一种情况,网站如果使用cdn的并且开启代码优化的话,注视也会被过滤掉…

所以,注释这种的方式好像不是很安全

@emn178
Copy link
Owner

emn178 commented Jan 4, 2016

Hi,

感謝你的建議, 未來將考慮增加其他的方式改善這個問題, 可能的方式是用屬性實現

@hyingzi hyingzi closed this as completed Jan 4, 2016
@emn178
Copy link
Owner

emn178 commented Feb 18, 2016

Hi, 805063c 新增兩種使用方式可解決此問題

@hyingzi
Copy link
Author

hyingzi commented Mar 14, 2016

非常感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants