vendredi 10 avril 2015

Got runtime error, when inserting list item in to a paragraph tag

Look at the following code for example:



<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebApplication18._Default" %>

<!DOCTYPE html>
<html>
<body>
<p id="someId"></p>

<script type="text/javascript">
document.getElementById("someId").innerHTML = "<ul><li>Some content</li></ul>";
</script>
</body>


In the Visual Studio 2013, debug mode, I got a runtime error. I have noticed that the p tag doesn't allow any block-level tags within it according W3C rules.


But if I created a static html file, it runs fine.



<!DOCTYPE html>
<html>
<body>
<p id="someId"></p>
<script type="text/javascript">
document.getElementById("someId").innerHTML = "<ul><li>Some content</li></ul>";
</script>

</body>
</html>


I wonder why there is a runtime error when running with Visual studio, but it’s ok with a static file? Thanks. I am using visual studio 2013, and IE 11.





Aucun commentaire:

Enregistrer un commentaire