/    Sign up×
Community /Pin to ProfileBookmark

remove html element outsite <html>

hi,
my page was hacked by iframes which appeared like the following

<iframe src = “http://uri4r.ru:8080/index.php”></iframe>
<html>
<head>
</head>
<body>
</body>
</html>

i wrote a javascript code to remove all iframes but it removed only the iframes inside body tag but not outside the html tags…

is there anyway to prevent html elements outside html tag or is there a way to dynamically remove any element which gets inserted outside html tag?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@themartyJul 17.2009 — why are you trying to do this with javascript?

and where is this data stored and how is it displayed?
Copy linkTweet thisAlerts:
@Phill_PaffordJul 17.2009 — [CODE]
<iframe src = "http://jsbin.com/izapu">
<!-- Will remove this iFrame outside of the HTML -->
</iframe>
<iframe src = "http://jsbin.com/izapu">
<!-- Will remove multiple iFrames outside of the HTML -->
</iframe>
<html>
<head>
<script language="JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript">
</script>
<script type="text/javascript">
$(document).ready(function(){
// Check for iframe(s)
if($("iframe").length > 0) {
alert('iFrame(s) Exist');
$("iframe").remove();

// Check if they still exists
if($("iframe").length > 0) {
alert('iFrame(s) Still Exist');
}
}
});
</script>
</head>
<body>
<iframe src = "http://jsbin.com/izapu">
<!-- Will remove this iFrame in the HTML -->
</iframe>
<iframe src = "http://jsbin.com/izapu">
<!-- Will remove multiple iFrames in the HTML -->
</iframe>
</body>
</html>
[/CODE]
Copy linkTweet thisAlerts:
@CharlesJul 17.2009 — Here's my all purpose, put me in the top window script:&lt;script type="text/javascript"&gt;
if (self.opener) {
opener.location = self.location
self.close()
}
if (top.location != self.location) {
top.location.replace (self.location)
}
&lt;/script&gt;
×

Success!

Help @jayapalchandran spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...