Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi programmers,

i have html page that contains some java script codes in both head and body sections
i want to extract only the java script codes or javascript function from this html.

to be clear
i have javascript function called quiz(answer) i want to get the body of this function and display it in messagebox or whatever .

how can i do that using c#?

this is my complete html page


XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="Js/print.js"></SCRIPT>
<script src="Js/textsizer-zoom.js"></script>
<script src="Js/getCss.js"></script>
<script src="Js/getdata.js"></script>
<script src="Js/font_colors.js"></script>
<script src="Js/sound.js"></script>

<!--<link href="css/layout.css" rel="stylesheet" type="text/css" />-->
<link href="css/style.css" rel="stylesheet" type="text/css">
<link href="css/font_colors.css" rel="stylesheet" type="text/css">
<!--include jodes for display flashes and imajes-->
<link rel="stylesheet" type="text/css" href="demo_files/floatbox.css">
<script type="text/javascript" src="demo_files/framebox.js"></script>
<!--[if lte IE 6]>
<script type="text/javascript" src="/includes/ieHelper.js"></script>
<![endif]-->
<script type="text/javascript">
//<![CDATA[
fbPageOptions = {
    enableDragMove: false,
    enableDragResize: false,
    navType: 'both',
    showNavOverlay: 'once',
    slideInterval: 3,
    hideFlash: false,
    enableCookies: true,
    cookieScope: 'site'
};
fbChildOptions = {
    afterPrint: function() { fb.end(); }
};
<!--End of including-->
//]]>

</script>


<script type="text/javascript">
<!--
/*function showHideLayers(it_id,state)
{
    var menus = new Array();
    menus[0] = 'cont';
    menus[1] = 'help';
    menus[2] = 'prof';
    menus[3] = 'search';
    for(var i=0; i<4; i++)
     {
        if(menus[i] == it_id && state==1 )
         {
            document.getElementById(it_id).style.display='block';
            if(menus[i] == 'search') document.getElementById('searchFrame').src = 'searchresult.html?sw=' + document.searchForm.searchItem.value;
         }
        else
            document.getElementById(menus[i]).style.display='none';
    }
}*/
function showHideLayers(it_id,state)
{
document.getElementById(it_id).style.display='block';
if( state==0)
    {
      document.getElementById(it_id).style.display='none';
    }
else
    {
        document.getElementById(it_id).style.display='block';
    }
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}
//-->
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function enabled() {
        document.form1.radiobutton[0].disabled = false;
        document.form1.radiobutton[1].disabled = false;
        document.form1.radiobutton[2].disabled = false;
        }
</script>

<!--For search-->
            <script language="javascript">function killerrors(){return true;}window.onerror = killerrors;</script>
            <script language="JavaScript">

            function OnSearchSubmit()
{
    var b_return=true;
    if (document.form_search.sw)
    {
        for(var i=0;i<document.form_search.sw.value.length;i++)
        {
            if (document.form_search.sw.value.charAt(i)!=" ")
            {
                lh="searchresult.html?sw="+encodeURIComponent(document.form_search.sw.value);
                b_return=false;break;
            }
        }
    }
    if (b_return) return;
    $.cookie("search_item", document.form_search.sw.value , { expires: 7 });
    document.getElementById("search_iframe").src = lh;
    $.prettyPhoto.open('#inline_search');
    //window.open(lh,"_self");
    }
 $(document).ready(function() {
     $(function() {
     pathArray = window.location.pathname.split( '/' );
     current_url = pathArray[pathArray.length-1];
  $('#nav-list li a').each(function() {
    if ($(this).attr('href')  ===  current_url) {
      $(this).addClass('current');
    }
  });
});
 });

</script>
<style type="text/css">
<!--
.style2 {font-size: 14px}
#apDiv1 {
    position:absolute;
    left:52px;
    top:536px;
    width:84px;
    height:28px;
    z-index:1;
    background-color: #6699FF;
}
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
.style20 {  color: #AD3333;
    font-weight: bold;
}
.style22 {color: #3074B7}
-->
</style>
</head>
<form name="testform">
<input type="hidden" name="testinput" value="0" />
</form>
<body onload="getColors();getFontSize();MM_preloadImages('buttons/template_03.jpg','buttons/template_05.jpg','buttons/template_09.jpg','buttons/template_11.jpg','images/template_07.jpg')">
<div class="style20" id="apDiv1" style="display:none" onmouseover="javascript:document.getElementById('apDiv1').style.display='block'" onmouseout="javascript:document.getElementById('apDiv1').style.display='none'">

<script type="text/javascript">

function quiz(answer) {
    var answerComments = new Array(),rightAnswer;
    answerComments[0] = "At 2 years  old   ossification centre appears in the lower end of radius";
    answerComments[1] = "opened anterior fontanelle.is not exception because it closes at 18 – 24 months";
    answerComments[2] = "body weight  is about 12kg at 2 years  old ";
    rightAnswer =1;
    document.getElementById('feedBack').style.display = 'block';
    if(answer == rightAnswer ) {
        document.getElementById('answerTitle').innerHTML = 'Correct answer';
        document.getElementById('answerTitle').className = 'style20';
        document.getElementById('answer_Comments').innerHTML = answerComments[answer];
        document.image.src = 'images_normal/right-answer.png';
        document.getElementById('nextQuestion').style.display = 'block';
        document.form1.radiobutton[0].disabled = true;
        document.form1.radiobutton[1].disabled = true;
        document.form1.radiobutton[2].disabled = true;
    } else {
        document.getElementById('answerTitle').innerHTML = 'Wrong answer';
        document.getElementById('answerTitle').className = 'style23';
        document.getElementById('answer_Comments').innerHTML = answerComments[answer];
        document.image.src = 'images_normal/wrong-answer.png';
        document.getElementById('nextQuestion').style.display = 'none';
        document.form1.radiobutton[0].disabled = false;
        document.form1.radiobutton[1].disabled = false;
        document.form1.radiobutton[2].disabled = false;
    }

}


</script>

  <table  border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td valign="top"><div id="larg" ><a href="javascript:ts('main_content',1)"><img src="images/finc.jpg" width="27" height="28" /></a></div></td>
      <td valign="top"><a href="javascript:rs('main_content')"><img src="images/fnorm.jpg" width="27" height="28" /></a></td>
      <td valign="top"><div id="small"><a href="javascript:ts('main_content',-1)"><img src="images/fdec.jpg" width="27" height="28" /></a></div></td>
    </tr>
  </table>
</div>
<!-- ImageReady Slices (English t.psd) -->
<!-- DIV ID="exp1" -->

<table width="800" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="97" colspan="22" valign="top" background="images/template_01.jpg"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="25%" height="38">&nbsp;</td>
        <td width="19%">&nbsp;</td>
        <td width="56%">
        <div id="google">
        <form method="get" action="http://www.google.com/search" target="_blank">
<div style="border:0px solid black;padding:4px;width:20em;">
<table border="0" cellpadding="0">
<tr><td>
<input type="text"   name="q" size="25"
 maxlength="255" value="" />
<input type="submit" value="Google Search" /></td></tr>
<tr><td align="center" style="font-size:75%">
</td></tr></table>
</div>
</form>
        </div>
        </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="images/template_02.jpg" /></td>
        <td><a href="slide_01.html" target="_top" onclick="MM_nbGroup('down','group1','template03','buttons/template_03.jpg',1)" onmouseover="MM_nbGroup('over','template03','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/template_03.jpg" alt="" name="template03" width="82" height="27" border="0" id="template03" onload="" /></a></td>
        <td><img src="images/template_04.jpg" /></td>
        <td><a href="activity.html" target="_top" onclick="MM_nbGroup('down','group1','template05','buttons/template_05.jpg',1)" onmouseover="MM_nbGroup('over','template05','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/template_05.jpg" alt="" name="template05" width="81" height="27" border="0" id="template05" onload="" /></a></td>
        <td><img src="images/template_06.jpg" /></td>
        <td><a href="quiz.html" target="_top" onclick="MM_nbGroup('down','group1','template07','buttons/template_07.jpg',1)" onmouseover="MM_nbGroup('over','template07','','',1)" onmouseout="MM_nbGroup('out')"><img src="buttons/template_07.jpg" alt="" name="template07" border="0" id="template07" onload="MM_nbGroup('init','group1','template07','images/template_07.jpg',1)" /></a></td>
        <td><img src="images/template_08.jpg" /></td>
        <td><a href="glossary.html" target="_top" onclick="MM_nbGroup('down','group1','template09','buttons/template_09.jpg',1)" onmouseover="MM_nbGroup('over','template09','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/template_09.jpg" alt="" name="template09" width="81" height="27" border="0" id="template09" onload="" /></a></td>
        <td><img src="images/template_10.jpg" /></td>
        <td><a href="summary.html" target="_top" onclick="MM_nbGroup('down','group1','template11','buttons/template_11.jpg',1)" onmouseover="MM_nbGroup('over','template11','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/template_11.jpg" alt="" name="template11" width="81" height="27" border="0" id="template11" onload="" /></a></td>
      </tr>
    </table></td>
    <td colspan="12" width="382"  background="images/template_12.jpg"></td>
  </tr>
  <tr>
    <td colspan="32" background="images/template_14.jpg" height="28" ><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td align="left" valign="middle"><div id="s1"  >
          <form  action="javascript:OnSearchSubmit()" name="form_search" id="form_search"  >
            <table>
              <tr>
                <td valign="bottom"><input type="text" name="sw" id="s1" style="text-align:center; color:#663333;" value="ابحث هنا" onclick="this.value=''" onblur="if(this.value == '')this.value='ابحث هنا'" title="إحرص على كتابة الكلمة بطريقة إملائية صحيحة" /></td>
                <td  ><label>
                  <input type="submit" name="button" id="button" value="Search"  />
                  </label>
                </td>
              </tr>
            </table>
          </form>
        </div></td>
        <td width="53%">&nbsp;</td>
        <td width="15%" align="right"><table width="115" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><a href="javascript:;" title="Content" target="_top" onClick="showHideLayers('cont','1')"><img src="images/template_16.jpg" width="29" height="33" alt="" title="Content" /></a></td>
            <td><a href="javascript:;" title="Help" target="_top" onClick="showHideLayers('help','1');"><img src="images/template_17.jpg" width="27" height="33" alt="" title="Help"/></a></td>
            <td><a href="javascript:;" target="_top" onClick="showHideLayers('prof','1');"><img src="images/template_18.jpg" width="28" height="33" alt="" title="Contact" /></a></td>
            <td><img src="images/template_19.jpg" width="30" height="33" alt="" title="Home"/></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="32" height="30" background="images/template_20.jpg">&nbsp;</td>
  </tr>
  <tr>
    <td  colspan="32"><table width="100%" height="354" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td bgcolor="#F1FFFF" class="content_box" id="main_content"><table width="94%" height="344" border="0" align="center" cellpadding="0" cellspacing="0" class="content">
          <tr>
            <td width="18%" height="21" align="center" bgcolor="#DBE3FD" class="style20">Quize</td>
            <td width="82%">&nbsp;</td>
          </tr>
          <tr>
            <td height="323" colspan="2" valign="top" style="border:1px solid #DBE3FD;"><blockquote> <br />
                    <table width="80%" border="0" align="center" cellpadding="0" cellspacing="4">
                      <tr>
                        <td align="left" class="content_box1"><span class="style22">A 2 years old child shows the following excep</span></td>
                      </tr>
                    </table>
              <br />
                    <table width="80%" border="0" align="center" cellpadding="0" cellspacing="4">
                      <tr>
                        <td align="center" class="content_box1"><form action="" method="post" name="form1" id="form1">
                            <table width="100%" border="0" cellspacing="4" cellpadding="4">
                              <tr>
                                <td width="5%" align="left">&nbsp;</td>
                                <td width="6%" align="left"><label>
                                  <input name="radiobutton" type="radio" value="0" onclick="quiz(this.value);" />
                                </label></td>
                                <td width="89%" align="left"><span class="style22">a .</span> ossification centre appears in the lower end of radius </td>
                              </tr>
                              <tr>
                                <td align="left">&nbsp;</td>
                                <td align="left"><label>
                                  <input name="radiobutton" type="radio" value="1" onclick="quiz(this.value);" />
                                </label></td>
                                <td align="left"><span class="style22">b . </span> opened anterior fontanelle </td>
                              </tr>
                              <tr>
                                <td align="left">&nbsp;</td>
                                <td align="left"><label>
                                  <input name="radiobutton" type="radio" value="2" onclick="quiz(this.value);" />
                                </label></td>
                                <td align="left"><span class="style22">c .</span> body wt. about 12kg </td>
                              </tr>
                            </table>
                        </form></td>
                      </tr>
                    </table>
              <br />
                    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="4">
                      <tr>
                        <td height="106" align="left" class="content_box1"><div id="feedBack" style="display:none;">
                            <table width="91%" height="94" border="0" align="center" cellpadding="0" cellspacing="0">
                              <tr>
                                <td colspan="3" align="center" bgcolor="#ACCAE8"  ><strong>
                                  <div id="answerTitle"></div>
                                </strong></td>
                              </tr>
                              <tr>
                                <td width="17%" rowspan="2" align="center" bgcolor="#ACCAE8"><table width="95%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td height="62" align="center" class="content_box1"><img src="images_normal/wrong-answer.png" alt="" name="image" id="image" /></td>
                                    </tr>
                                </table></td>
                                <td width="61%" rowspan="2" align="center" bgcolor="#ACCAE8"><table width="95%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td height="62" align="center" class="content_box1"><div id="answer_Comments"></div></td>
                                    </tr>
                                </table></td>
                                <td width="22%" bgcolor="#ACCAE8">&nbsp;</td>
                              </tr>
                              <tr>
                                <td height="46" align="center" bgcolor="#ACCAE8" ><div id="nextQuestion" style="display:none;"><a href="quiz2.html"><span class="pos"> Next Question </span></a></div></td>
                              </tr>
                            </table>
                        </div></td>
                      </tr>
                    </table>
              <br />
            </blockquote></td>
          </tr>
        </table></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="32"><img src="images/template_26.jpg" width="800" height="5" alt="" /></td>
  </tr>
  <tr >
    <td  colspan="32" ><table width="100%" height="33" border="0" cellspacing="0" cellpadding="0" background="images/template_336.jpg">
      <tr>
        <td width="20%"><table height="33" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="8">&nbsp;</td>
            <td width="35">
            <span>
                 <a href="javascript:;" title="Font Color" >
                 <script language="JavaScript">
            new tcal ({
                // form name
                'formname': 'testform',
                // input name
                'controlname': 'testinput'
            });
        </script>
            </a>          </span>            </td>
            <td width="34"><a href="javascript:;" onclick="javascript:document.getElementById('apDiv1').style.display='block'" onmouseout="javascript:document.getElementById('apDiv1').style.display='none'"><img src="images/template_30.jpg" width="34" height="33" alt="" title="Font Size"/></a></td>
            <td width="34"><a href="javascript:window.print()"><img src="images/template_32.jpg" width="34" height="33" alt="" title="Print"/></a></td>
            <td width="35"><a href="#notes" title="" class="floatbox" rev="width:350 height:250 scrolling:no colorHTML:blue"><img src="images/template_34.jpg" width="35" height="33" alt="" title="Notes"/></a></td>
          </tr>
        </table></td>
        <td width="64%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="73">Slide (1/5)</td>
            <td width="439"><select name="jumpMenu" style="width:350px" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
              <option value="slide_01.html">Definition</option>
              <option value="slide_02.html" >Main points</option>
              <option value="slide_03.html">1- Legal identification</option>
              <option value="slide_04.html">2- Personal or civil identification</option>
              <option value="slide_05.html">3- Criminal identification</option>
              <option value="activity.html">Activity</option>
              <option value="quiz.html" selected>Quiz - First question</option>
              <option value="quiz2.html">Quiz - Second question</option>
              <option value="quiz3.html">Quiz - Third question</option>
              <option value="glossary.html">Glossary</option>
              <option value="summary.html">Summary</option>
            </select></td>
          </tr>
        </table></td>
        <td width="16%"><table width="77%" height="33" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="5%">&nbsp;</td>
            <td width="19%"><img src="images/template_37.jpg" width="35" height="33" alt="" title="Back"/></td>
            <td width="18%"><a href="javascript:;" title="Refresh" target="_top" onClick="window.location.reload( true )"><img src="images/template_39.jpg" width="34" height="33" alt="" title="Refresh"/></a></td>
            <td width="18%"><img src="images/template_41.jpg" width="34" height="33" alt="" title="Next" /></td>
            <td width="40%">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="32"><img src="images/template_43.jpg" width="800" height="20" alt="" /></td>
  </tr>
  <tr>
  <td>
  </td>
  </tr>
</table>




<!-- End ImageReady Slices -->
<!-- Layer "prof" -->
<div id="prof">
<div class="shiftcontainer">
<div class="shadowcontainer">
<div class="innerdiv">
  <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td width="94%" rowspan="2"><iframe src="prof_cv.html" width="100%" height="550px" frameborder="0"> </iframe></td>
    <td width="6%" valign="top"><a href="javascript:;"onclick="showHideLayers('prof','0')"><img src="images_normal/close.png" alt="Close" width="34" height="31" border="0" /></a></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    </tr>
</table>
</div>
</div>
</div>
</div>

<!-- Layer "help" -->
<div id="help">
<div class="shiftcontainer">
<div class="shadowcontainer">
<div class="innerdiv">
  <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td width="94%" rowspan="2"><iframe src="help.html" width="100%" height="350px" frameborder="0"> </iframe></td>
    <td width="6%" valign="top"><a href="javascript:;"onclick="showHideLayers('help','0')"><img src="images_normal/close.png" alt="Close" width="34" height="31" border="0" /></a></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    </tr>
</table>
</div>
</div>
</div>

</div>
<!-- Layer "cont" -->
<div id="cont">
<div class="shiftcontainer">
<div class="shadowcontainer">
<div class="innerdiv">
  <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td width="94%" rowspan="2"><iframe src="content.html?p=2" width="100%" height="500px" frameborder="0"> </iframe></td>
    <td width="6%" valign="top"><a href="#"onclick="showHideLayers('cont','0')"><img src="images_normal/close.png" alt="Close" width="34" height="31" border="0" /></a></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    </tr>
</table>
</div>
</div>
</div>
</div>
<!-- from mansoura template-->
<div id="inline_search" style="display:none;">
<iframe id="search_iframe"  width="500px" height="262" style="border:none;">
</iframe>
</div>


<div id="notes" style="display:none">
<div id="intro" style="padding-right:13px; padding-left:13px; z-index:2; left:0px; padding-bottom:13px; overflow:auto; width:348px; cursor:pointer; padding-top:5px; position:absolute; top:27px; height:213px" onClick="clrIntroLyr()"></div>
<!-- MEMO-PAD -->
<form name="f1">
<div id="head_table" style="background:#00009C; left:0px; width:350px; position:absolute; top:0px; height:240px; text-align:center">
<TABLE border=0 style="font-size:12px; width:100%; color:#ffffff; text-align:left">
<TBODY>
<TR>
<TD width=110><strong>Write Your Notes</strong></TD>
<TD> <strong>Caracters</strong></TD>
<TD>
<div id="remainder">0000</div></TD>
<TD align=middle><A href="#null" style="color:#ffffff;" onClick="showHide('conFirm')" title="Delete the cookie and memo Contents">Delete</A></TD>
<TD align=middle><A href="#null" style="color:#ffffff;" onClick="emailMemo()" title="E-mail the memo contents">E-Mail</A></TD>
<td align="center"><a href="javascript:window.print()" style="color:#ffffff;" onClick="printMemo()" title="Print the memo contents">Print</A></td>
<TD align=middle><A href="#null" style="color:#ffffff;" onClick="self.close()" title="Save and & close Memo-Pad">Save</A></TD>
</TR>
</TBODY>
</TABLE>
<TEXTAREA id="the_pad" style="border-right:#908460 4px ridge; border-top:#908460 4px ridge; font-size:12px; overflow:auto; border-left:#908460 4px ridge; width:346px; color:#6b3908; line-height:15px; border-bottom:#908460 4px ridge; height:220px; background-color:#ffffff; text-align:left" rows=1></TEXTAREA>
</div>
</form>

<!-- CONFIRM div -->
<div id="conFirm" style="border-right:#808080 2px solid; border-top:#ffffff 2px solid; font-weight:bold; z-index:5; background:#c9bda9; left:50px; VISIBILITY:hidden; border-left:#ffffff 2px solid; width:250px; color:#ffffff; border-bottom:#808080 2px solid; position:absolute; top:65px">
<div style="filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=1,StartColorStr='#FF9f9573', EndColorStr='#FFc9bda9'); height:20px"> JavaScript Source</div>
<P>
<p style="text-align: center;">
<font color="black" size="2">Are you sure you want to delete your memo?</font>
</p>
<FORM>
<span style="border-right:#000000 1px groove; border-top:#000000 1px groove; left:50px; border-left:#000000 1px groove; width:75px; border-bottom:#000000 1px groove; position:relative; top:10px; height:22px"><INPUT style="border-right:#ffffff 1px outset; border-top:#ffffff 1px outset; font-size:10px; border-left:#ffffff 1px outset; width:74px; border-bottom:#ffffff 1px outset; height:20px" onClick="deleteMemo();showHide('conFirm')" type="button" value="Yes">
</span>
<span style="border-right:#000000 1px groove; border-top:#000000 1px groove; left:65px; border-left:#000000 1px groove; width:75px; border-bottom:#000000 1px groove; position:relative; top:10px; height:22px"><INPUT style="border-right:#ffffff 1px outset; border-top:#ffffff 1px outset; font-size:10px; border-left:#ffffff 1px outset; width:74px; border-bottom:#ffffff 1px outset; height:20px" onClick="showHide('conFirm')" type="button" value="No">
</span>
</FORM>
</div>

</div>

</body>
</html>
Posted
Comments
OriginalGriff 10-Apr-11 5:16am    
What have you tried?
progahmed 10-Apr-11 5:44am    
hi Mr. OriginalGriff

i tried the following

private string Quiz(string content)
{
string test = content.ToLower();// to eliminate case sensitivity
int x = test.IndexOf("quiz(answer) {");

int y = test.LastIndexOf("</script>");


return content.Substring(x + 1, y);
}

the content is passed to this method comes from webbrowser1.Document.ToString() but
nothing happened and the body section contains another javascript code

could you help me
[no name] 10-Apr-11 8:22am    
Is there a reason for doing this?
progahmed 10-Apr-11 11:41am    
yes ,

the reason is i have 250 html page with 250 different javascript function [quiz(answer)]. so i need to get the body of this javascript function [quiz(answer)]. and put it in a new 250 html page with different template design.

so i want to do this dynamically.
[no name] 10-Apr-11 12:14pm    
you should be using external javascript files to do this. What happens when one of the method changes, do you expect to replace it in all 250 files? Wouldn't making a change in one file be more effeciant?

You need to parse HTML and take of Javascript nodes found by the script Element. This task depends on one important item: can you assume that HTML is a valid XML? Is so, you can use one if the .NET XML parsers.

Chances are, you cannot. In this case, look at one of available HTML parser in C#. The following projects are found in CodeProject:
An Elementary HTML Parser[^]
Another C# Legacy HTML Parser Using Tag Processing[^]
AfterWork HTML Parser in C#[^].

If this is not enough, do your own search:
http://en.lmgtfy.com/?q=HTML+parser+%22C%23%22[^].

Sharpen your Google skills, by the way; it will greatly help you.

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 10-Apr-11 16:20pm    
Good advice, my 5
Sergey Alexandrovich Kryukov 10-Apr-11 16:22pm    
Thank you, Espen.
The solution is quite feasible, hope some of the references can help well.
--SA
Espen Harlinn 10-Apr-11 16:33pm    
OP may, as I mentioned below, even use the WebBrowser control - as the pages seem to be static
Sergey Alexandrovich Kryukov 10-Apr-11 20:54pm    
Your answer is interesting, I already voted :-)
--SA
As SAKryukov points out there is a number of html parsers available, including WebBrowser[^]

Take a look at The most complete C# Webbrowser wrapper control[^] for a few ideas on how you may use IE to perform your work.

Regards
Espen Harlinn
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Apr-11 19:12pm    
Good reply, my 5.
--SA
Espen Harlinn 11-Apr-11 14:53pm    
Thank you, SAKryukov!
Thanks to all

I developed so simple method that solve the problem it depends of the indexof("quiz(answer) {") and last index of ("").

and then get what between them.

this is my Developed method

C#
public string Quiz()
          {
             string script = br.DocumentText.ToString();
             int x = script.IndexOf("quiz(answer) {");
             int y = script.LastIndexOf("</script>");
             script = script.Substring(x ,y-x);
             return script;
           }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900