webView加载html动态创建标签

webView加载html有时需要对HTML页面进行动态操作,需动态添加标签事件.主要代码如下:
加载webView和设置代理就不记录了。

- (void) webViewDidFinishLoad:(UIWebView *)webView
{
    [self deleteCookie];
    //添加home
    [webView stringByEvaluatingJavaScriptFromString:
      @"var para=document.createElement('a');"
      "para.style.color ='rgb(253,55,96)';"
      "para.style.text-decoration='none';"
      "para.style.position='absolute';"
      "para.style.right='10px';"
      "para.style.top='0px';"
      "var node = document.createTextNode('home');"
      "para.appendChild(node);"
      "para.href = 'http://localhost:63342/hlhCodeH5/html/index.html?memberId=10000519300&mobile=13522366549';"
      "para.style.font-size ='15px';"
      "document.getElementsByClassName('header_nav')[0].appendChild(para);"
     ];
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值