之前学过html,能做出简单的搭页,但在考虑兼容性问题上自觉感觉很复杂。今天在js上发现了删除上格浏览器的不同:
| <!DOCTYPE html> | | <html lang="en"> | | <head> | | <meta charset="UTF-8"> | | <title>Document</title> | | <script type="text/javascript"> | | function addstyle(){ | | var sheet=document.createElement('style'); | | sheet.setAttribute('id','myid'); | | document.body.appendChild(sheet); | | if(sheet.styleSheet==undefined){ | | sheet.innerHTML='div{width:200px;height:200px;border:1px solid blue;float:left;margin-left:10px;}'; | | } | | else | | { | | sheet.styleSheet.cssText='div{width:200px;height:200px;border:1px solid blue;float:left;margin-left:10px;}'; | | } | | | | } | | function removestyle(){ | | var delstyle=document.getElementById('myid'); | | delstyle.parentNode.removeChild(delstyle); | | } | | </script> | | </head> | | <body> | | <div></div> | | <div></div> | | <div></div> | | <input type="button" value="add" onclick="addstyle()"> | | <input type="button" value="remove" onclick="removestyle()"> | | </body> | | | | </html> | 这只是在删除上的小改变,期望着学更多关于别的兼容问题的解决方法 | |