.net如何获取页面中的meta信息。 如何获取页面中的meta信息。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 父页面中有iframe(src=son.html)在son.html中如何获取父页面的meta信息。metas = window.parent.document.getElementsByTagName("meta")for(i=0;i<metas.length;i++){alert(metas[i].getAttribute("name"))alert(metas[i].getAttribute("content"))}metas[i].setAttribute("content","new value") code=C#]public static string GetSingleTagValueByAttr(string inputstring, string tagName, string attrname, string key)[Regex reg = new Regex("<" + tagName + " [^<>]*>", RegexOptions.IgnoreCase);MatchCollection matchs = reg.Matches(inputstring);string result = string.Empty;foreach (Match match in matchs){string matchValue = match.Value;Regex regValue = new Regex("content=".*"", RegexOptions.IgnoreCase);if (matchValue.ToLower().IndexOf(attrname.ToLower() + "="" + key.ToLower() + """) != -1){if (regValue.IsMatch(matchValue)){result = regValue.Match(matchValue).Value;if (!string.IsNullOrEmpty(result)){result = result.Replace("CONTENT=", "").Replace("content=","").Replace(""", "");}}return result;}}return null;}//使用举例://获取关键词 GetSingleTagValueByAttr(data, "meta", "name", "Keywords"); data是HTML源代码//获取描述GetSingleTagValueByAttr(data, "meta", "name", "Discription");//读取封闭标签的内容:private string GetFixTagContent(string inputstring,string tagName){string leftTag = "<" + tagName + ">";string rightTag="";Regex reg = new Regex("<" +tagName+"[^<>]*>(.|\n)*" + rightTag,RegexOptions.IgnoreCase);return reg.Match(inputstring).Value.Replace(leftTag, "").Replace(rightTag, "");}//使用举例:string title=GetFixTagContent(sourceHTML,"title");[/code]{ metas = document.getElementsByTagName("meta") FreeTextBox控件怎么只获取其内容不要html ASP.NET网站的更新问题 各位帮我看看这段代码为什么没有按顺序执行! 求vs.net2005下載地址 快来看啊。 帮忙想想办法吧,关于分组显示的问题! 在asp.net中怎样精确定位控件的位置? 编程爱好者请进 思规-------请问一个正则表达式 倾情奉献:本人写的客户端控件验证,挑战Microsoft的验证控件 .net如何防止同一同时用户多次登录 Gridview表头中添加checkbox,可以全选列中的checkbox,同时列中要有checkbox和textbox,我我我我要崩溃了
在son.html中如何获取父页面的meta信息。
metas = window.parent.document.getElementsByTagName("meta")
for(i=0;i<metas.length;i++)
{
alert(metas[i].getAttribute("name"))
alert(metas[i].getAttribute("content"))
}metas[i].setAttribute("content","new value")
public static string GetSingleTagValueByAttr(string inputstring, string tagName, string attrname, string key)
[
Regex reg = new Regex("<" + tagName + " [^<>]*>", RegexOptions.IgnoreCase);
MatchCollection matchs = reg.Matches(inputstring);
string result = string.Empty;
foreach (Match match in matchs)
{
string matchValue = match.Value;
Regex regValue = new Regex("content=".*"", RegexOptions.IgnoreCase);
if (matchValue.ToLower().IndexOf(attrname.ToLower() + "="" + key.ToLower() + """) != -1)
{
if (regValue.IsMatch(matchValue))
{
result = regValue.Match(matchValue).Value;
if (!string.IsNullOrEmpty(result))
{
result = result.Replace("CONTENT=", "").Replace("content=","").Replace(""", "");
}
}
return result;
}
}
return null;
}//使用举例://获取关键词
GetSingleTagValueByAttr(data, "meta", "name", "Keywords"); data是HTML源代码
//获取描述
GetSingleTagValueByAttr(data, "meta", "name", "Discription");//读取封闭标签的内容:
private string GetFixTagContent(string inputstring,string tagName)
{
string leftTag = "<" + tagName + ">";
string rightTag="";Regex reg = new Regex("<" +tagName+"[^<>]*>(.|\n)*" + rightTag,RegexOptions.IgnoreCase);
return reg.Match(inputstring).Value.Replace(leftTag, "").Replace(rightTag, "");
}
//使用举例:
string title=GetFixTagContent(sourceHTML,"title");
[/code]{