Pogledajte određenu poruku
Staro 25. 08. 2011.   #2
webarto
expert
Grand Master
 
Avatar webarto
 
Datum učlanjenja: 11.04.2010
Poruke: 998
Hvala: 141
959 "Hvala" u 153 poruka
webarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished road
Default

http://ideone.com/t12Yf

PHP kôd:
$html '<html>
<body>
<script>alert("hello");</script>
Field1: <input type="text" id="field1" value="Hello World!" />
<br />
<button onblur="document.getElementById(\'field1\').value=document.getElementById(\'field2\').value">Copy Text</button>
Field2: <input type="text" id="field2" />
<br /><br />
Click the button to copy the content of Field1 to Field2.
<br />
<button onclick="document.getElementById(\'field2\').value=document.getElementById(\'field1\').value">Copy Text</button>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
</body>
</html>'
;


$javascript NULL;

preg_match_all("#<script>(.*?)</script>#is"$html$matches);
foreach(
$matches[1] as $match){
    
$javascript[] = $match;
}

preg_match_all("#(onblur|onchange|onclick|ondblclick|onerror|onfocus|onkeydown|onkeypress|onkeyup|onload|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onresize|onselect|onunload)=\"(.*?)\"#is"$html$matches);
foreach(
$matches[2] as $match){
    
$javascript[] = $match;
}

print_r($javascript); 
Citat:
Array
(
[0] => alert("hello");
[1] => document.getElementById('field1').value=document.g etElementById('field2').value
[2] => document.getElementById('field2').value=document.g etElementById('field1').value
)
Treba li ti linkovani JS?
__________________
Github // LinkedIn // PHP // ZCE // Stackoverflow PHP // Site5 Web Hosting
webarto je offline   Odgovorite uz citat
"Hvala" webarto za poruku: