Windows Phone 8 用のアプリケーションを開発しています。
基本的に、アプリケーションは 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);
したがって、基本的にコンテンツには、ローカル データベースから取得された div と動的コンテンツが含まれます。
HTMLコンテンツを動的に追加する許可を許可するために使用できる他の解決策または設定がある場合は、私を助けてください。
ありがとうございます。それでは、お元気で