[英]append lt IE using document.createElement
這是我的代碼:
function addTag(name, attributes, sync, cond) {
var el = document.createElement(name),
attrName;
for (attrName in attributes) {
el.setAttribute(attrName, attributes[attrName]);
}
sync ? document.write(outerHTML(el)) : headEl.appendChild(el);
}
function outerHTML(node){
// if IE, Chrome take the internal method otherwise build one
return node.outerHTML || (
function(n){
var div = document.createElement('div'), h;
div.appendChild(n);
h = div.innerHTML;
div = null;
return h;
})(node);
}
這是我的電話:
addTag('script',{"src":"\/\/oss.maxcdn.com\/html5shiv\/3.7.2\/html5shiv.min.js"},1,'lt IE 9');
如何在代碼中放置less than
標簽? 這個論點是cond
你可以嘗試:
function addTag(name, attributes, sync, cond) {
var el = document.createElement(name),
attrName,
condElement
;
for (attrName in attributes) {
el.setAttribute(attrName, attributes[attrName]);
}
switch (cond) {
case 'lt IE 9':
el = document.createComment(
'[if lt IE 9]>' + outerHTML(el) + '<![endif]'
);
break;
}
sync ? document.write(outerHTML(el)) : headEl.appendChild(el);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.