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
<!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/style.css" rel="stylesheet" type="text/css">
<link href="css/font_colors.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="demo_files/floatbox.css">
<script type="text/javascript" src="demo_files/framebox.js"></script>
<script type="text/javascript">
//<![CDATA[
</script>
<script type="text/javascript">
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>
<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">
</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>
<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"> </td>
<td width="19%"> </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%"> </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"> </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%"> </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"> </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"> </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"> </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"> </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"> </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%"> </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%"> </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>
<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> </td>
</tr>
</table>
</div>
</div>
</div>
</div>
<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> </td>
</tr>
</table>
</div>
</div>
</div>
</div>
<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> </td>
</tr>
</table>
</div>
</div>
</div>
</div>
<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>
<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>
<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>