一千萬個為什麽

搜索

更改youtube embended鏈接的內容

This is a very simple complexive query that I have. I need the solution. I have a youtube link

 <----- width="480" height="350"><----
 src="http://www.youtube.com/v/OORDOd6wRrE&hl=en_US&fs=1"
 type="application/x-shockwave-flash" allowscriptaccess="always"
 allowfullscreen="true" width="480" height="350"><---><----->

this is the modified link. Well, my problem is, that I want to change the size of video, means in the whole string I want to replace width="480" with width="250" and height="350" with height="250"

我想使用ASP.Net以編程方式更改這些參數

謝謝

最佳答案

我得到了解決方案。

Define one user define function
private bool IsInt(string IntValue)
{
      try
      {
            int iValue = int.Parse(IntValue);
      }
      catch (Exception Ex) { return false;}

     return true;
}

    string str=txt_Links.Text;
    string lastNo = "";
    bool firstNoFound = false;
    for (int strIdx = 0; strIdx <= str.Length - 1; strIdx++)
    {
        if (IsInt(str.Substring(strIdx, 1)) == true)
        {
            lastNo = lastNo + str.Substring(strIdx, 1);
            firstNoFound = true;
        }
        else
        {
            if (firstNoFound == true)
            {
                //Page.Title = lastNo;
                str = str.Replace("width=\"" + lastNo + "\"", "width=\"250\"").Replace("height=\"" + lastNo + "\"", "height=\"250\"");
                lastNo = "";
                firstNoFound = false;
            }
        }
    }

    Response.Write(str);

轉載註明原文: 更改youtube embended鏈接的內容