Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在WindowsPhone8应用程序中动态添加HTML_Javascript_Jquery_Html_Jquery Mobile_Windows Phone 8 - Fatal编程技术网

Javascript 在WindowsPhone8应用程序中动态添加HTML

Javascript 在WindowsPhone8应用程序中动态添加HTML,javascript,jquery,html,jquery-mobile,windows-phone-8,Javascript,Jquery,Html,Jquery Mobile,Windows Phone 8,我正在为WindowsPhone8开发一个应用程序 基本上,该应用程序是使用jQuery/jQuery Mobile、Javascript和HTML开发的,我想动态添加内容 每当我尝试执行此操作时,都会出现以下错误: 0x800c001c - JavaScript runtime error: Unable to add dynamic content. A script attempted to inject dynamic content, or elements previously mo

我正在为WindowsPhone8开发一个应用程序

基本上,该应用程序是使用jQuery/jQuery Mobile、Javascript和HTML开发的,我想动态添加内容

每当我尝试执行此操作时,都会出现以下错误:

0x800c001c - JavaScript runtime error: Unable to add dynamic content. A script attempted to inject dynamic content, or elements previously modified dynamically, that might be unsafe. For example, using the innerHTML property to add script or malformed HTML will generate this exception. Use the toStaticHTML method to filter dynamic content, or explicitly create elements and attributes with a method such as createElement.  For more information, see http://go.microsoft.com/fwlink/?LinkID=247104.
我搜索了它,发现由于安全原因,您无法动态添加HTML内容。我还发现,我们可以在函数中强制执行该操作:

MSApp.execUnsafeLocalFunction(function () {});
但问题是,在整个应用程序中,我必须动态添加HTML内容。因此,使用该函数编写任何添加的小内容都会有额外的开销

我要添加的HTML内容如下所示:

var Html = '<div class="boxgrid2 cover" style="background-image: url(images/' + varimage + '), url(images/BoxTrade.png);" ><div id="qty1" class="AniQty1 allfont">' + quantity + '</div><div id="name1" class="AniName1 allfont">' + varaname + '</div><div id="rate1" class="AniRate1 allfont">' + buyrate1 + '</div></div>';
$("#tradeAnimalDiv").html(Html);
var Html=''+quantity+''+varaname+''+buyrate1+'';
$(“#tradeAnimalDiv”).html(html);
所以基本上,内容包含从本地数据库获取的div和动态内容

如果有任何其他解决方案或设置可用于允许动态添加HTML内容,请帮助我


感谢和问候

您能提供一个您试图添加到DOM的内容示例吗?@Romain用我想添加的内容编辑了这个问题。您可能应该看看Windows Phone,不要将JavaScript用作应用程序语言。OP仍然嵌入在浏览器中。@ClausJørgensen感谢您的评论。基本上,我已经使用HTML5、jQuery/jQueryMobile开发了这个游戏,我想在WindowsPhone8中实现它。其他一切都进行得很顺利,只是当我动态添加一些HTMl内容时,会出现问题中所述的错误。您可以提供您试图添加到DOM中的内容的示例吗?@Romain用我要添加的内容编辑了问题。您可能应该看看Windows Phone,不要将JavaScript用作示例应用程序语言。OP仍然嵌入在浏览器中。@ClausJørgensen感谢您的评论。基本上,我已经使用HTML5、jQuery/jQueryMobile开发了这个游戏,我想在WindowsPhone8中实现它。其他一切都进展顺利,只是当我动态添加一些HTMl内容时,会出现问题中所述的错误。