在我的项目中,我将区域语言(malayalam)文本(长度:1900)从xcode WebViewDidFinishLoad传递到用html页面编写的javascript函数
function loadArticle(heading, img, desc, date){
document.body.scrollTop = 0;
if(img == null || img == "null"){
document.getElementById("image").style.display = "none";
}else{
addImg(img);
document.getElementById("image").style.display = "block";
}
addHeading(heading);
addDesc(desc);
addDate(date);
}
function addDesc(desc){
alert(desc); //is working fine . i can see my big text here
document.getElementById('description').innerHTML = desc;
return desc;
}
我也在使用这些元标记
<meta charset="UTF-8">
<script type="text/javascript" charset="UTF-8">
xcode中的
if (img!=NULL){
loadingString=[NSString stringWithFormat:@"loadArticle('%@','%@','%@','%@')",newNewsTitle,detail_ImageURL,trimmedDescString,detail_date];
[detail_webview stringByEvaluatingJavaScriptFromString:loadingString];
}else{
loadingString=[NSString stringWithFormat:@"loadArticle('%@','%@','%@','%@')",newNewsTitle,@"null",trimmedDescString,detail_date];
[detail_webview stringByEvaluatingJavaScriptFromString:loadingString];
}
}
[detail_webview stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"loadArticle('%@')",loadingString]];
在我的html部分
<body>
<div id="heading" style="font-size:26px;"></div>
<h6 id="date"></h6>
<p>
<img id="image" src="" width="auto" width="auto" style="margin-right:10px;margin-bottom:0px;"/>
<span id="description" width="320" style="font-size:18px;"> </span>
</p>
</body>
当我在xcode中硬编码并传递大文本然后它的工作正常(任何语言)但是当我从xml解析并从xcode传递值到html时它没有显示(javascript警告显示正确的值)。
请帮忙