Here's a sample code:
HTML
<script> alert('This is alert!') </script>
JS
window.alert = function(data) //alert() over-riding
{
scriptObject = document.currentScript; //gives me <script> object
}
Update: The above code doesn't seem to work now (It worked earlier, compatibility removed for IE) in Internet Explorer 11.420.10586.0. Why it is able to find the Script object in Chrome, Firefox, Safari and Microsoft Edge, but not in Internet Explorer? Is there any alternate way?
Issue:
HTML
<script> ReferenceError.prototype.__defineGetter__('name', function fff() { javascript:alert(1) }),x </script>
JS
window.alert = function(data) //alert() over-riding
{
scriptObject = ? // I need to get the Script object
}
I tried arguments.callee.caller
to find fff()
, but unable to catch the script object.
Alert() doesn't execute in Chrome for the above script. Use Firefox, instead. I couldn't get the script object in any browser.
Any solution please?