I'm building an article reading iOS app.Article contains multiple images.
I am unable to change the size of images in html.
here is my code:-
NSString *url=[[NSString alloc] initWithString:_DetailModal1[3] ];//contain html content.<br>
NSString *javaScriptStar=@"<script>a = document.getElementsByTagName('img');for (i = 0;i a.length;i++) {a[i].style.maxWidth = '600px';}</script><div style = \"line-height:85px;font-size:55px;font-family: Helvetica, Arial, Sans-Serif;font-weight:400;\">";
Please use the width
property instead of maxWidth
. Also your for loop is missing <
.
Please check this JSFiddle link
Here is the updated working code
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Click me</button>
<img border="0" src="http://t0.gstatic.com/images?q=tbn:ANd9GcS28hGdxjiRyMSuYNKY3ogoqKSZUZFRqlH93apAmZlJ-chii5EG"
alt="Pulpit rock" width="304" height="228"/>
<script>
function myFunction() {
var a = document.getElementsByTagName('img');
var i =0;
for (i = 0;i< a.length;i++)
{
a[i].style.width = '1000px';
}
}
</script>
</body>
</html>
NSString *url=[[NSString alloc] initWithString:_DetailModal1[3] ];//contain html content.
NSString *javaScriptStar=@"<style type=\"text/css\">img { width : 1000px !important; height:500px !important;}</style>";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.