So I would like to run the following Javascript on an open webpage in a UIWebView
:
- (IBAction)pushDownoad {
[webView stringByEvaluatingJavaScriptFromString:
var myWin=window.open("","myWin","width=800,height=600,scrollbars,resizable,menubar");
var myStr=document.documentElement.innerHTML.toLowerCase();
myStr=myStr.replace(/\</g,"<").replace(/\>/g,">").replace(/\r\n/g,"<br>");
var a=myStr.lastIndexOf("embed src=")+11;
var b=myStr.lastIndexOf("ec_rate");
myStr=myStr.substring(a,b);
myStr='<a href="'+myStr+'">Get Video</a>';
myWin.document.open();
myWin.document.write(myStr);
myWin.document.close();]
}
The whole point in this Javascript is to look for the text between two phrases and pull out that text from the source code. If this script is not usable how would i go about doing this so that the Javascript looks for text between two specific phrases(which will be a link) and then opens that link in the current UIWebView
.
Thank you so much to everyone.