/    Sign up×
Community /Pin to ProfileBookmark

[code=php]
<?php
$url_string = ‘http://’ . $_SERVER[‘SERVER_NAME’] . $_SERVER[‘REQUEST_URI’];
$parse_url = parse_url($url_string);
$host = $parse_url[‘host’];
$host_arr = explode(‘.’, $host);
$parts = count($host_arr);
$new_host = $host_arr[$parts – 2] . ‘.’ . $host_arr[$parts – 1];

if ($new_host != $host){
//echo ” ok if this url has not changed do nothing”;
}
else{

//echo ” ok if it did then trigger onunload event”;
}
/*
Ok if current window is no longer the same $new_host, such as if a frame breaker happen
or if a person closed current window, then it needs to trigger the onunload event, that would popup a php page.
*/
?>
[/code]

reason it needs to work like this is, because i will need to be able to click links in the frame and by just using a onunload event it seems i get a popup everytime i click a link, so now i am resorting to this method.

So if you know php and javascript, could use a little help in figuring this out.

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@ExuroJan 04.2005 — Would you please clarify as to when exactly you want the [FONT=courier new]onunload[/FONT] event to be executed?
Copy linkTweet thisAlerts:
@slimjimauthorJan 05.2005 — I want the onunload event to take place right after the current page is broken out of frames.
Copy linkTweet thisAlerts:
@ExuroJan 05.2005 — [i]Originally posted by slimjim [/i]

[B]I want the onunload event to take place right after the current page is broken out of frames. [/B][/QUOTE]

That's still pretty unclear, but I think I understand you now. You want the script to execute when the user leaves your frameset, right? If so, then here's some sample code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Frameset&lt;/title&gt;
[color=red]&lt;script type="text/javascript"&gt;
&lt;!--
onunload = function () {
alert("Leaving");
}
//--&gt;
&lt;/script&gt;[/color]
&lt;/head&gt;
&lt;frameset rows="*,*"&gt;
&lt;frame id="frame1" src="1.html" /&gt;
&lt;frame id="frame2" src="2.html" /&gt;
&lt;/frameset&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@slimjimauthorJan 05.2005 — That actually brings up the alert when the window closes and if i click on a link in the frame1, if a page loads in frame2 and has a frame breaker code on it, then my frameset just closes without even bringing up the alert.

I need it so that if a persons site is suppose to show in frame2 and that person has a frame breaker code on it, i want another page to popup so that I can report the site that is using a frame breaker code on it.
Copy linkTweet thisAlerts:
@NedalsJan 05.2005 — Put that script that Exuro provided in the page that's displayed in frame1. You know, of course, that the popup will be displayed whenever someone leaves your site.

What does "so that I can report the site that is using a frame breaker code" mean?
Copy linkTweet thisAlerts:
@slimjimauthorJan 05.2005 — Ok i have put that code in frame one, and of course i only see the alert when i close window or click on home in browser, refresh. But now when i use a link in the drop down box in address bar or when i go to a site that uses a frame breaker on it.

IT seems that what I need has to do with when the first part of the current url changes, like if it no longer says www.mysite.com and it says www.yoursite.com. Anything after the .com lets say, that will change of course, but if the domain name changes in general then i need the alert to happen.

This is driving me nuts, a little confusing as I do not know javascript and I know this requires it.
Copy linkTweet thisAlerts:
@ExuroJan 05.2005 — [i]Originally posted by slimjim [/i]

[B]IT seems that what I need has to do with when the first part of the current url changes[/B][/QUOTE]

JavaScript can't tell what URL the user is navigating to (for security purposes), so I don't think that solution's going to work.
Copy linkTweet thisAlerts:
@NedalsJan 06.2005 — Took another look.

I added this script in the page (frames02.html in this example) that might be replaced by the 'frame busting' page.

It gives you a popup, and then rejects the 'frame busting' page.
[size=1]
&lt;script type="text/javascript"&gt;
onunload = function() { alert('Framebust not allowed'); location.href='frames02.html'; }
&lt;/script&gt;
[/size]
Copy linkTweet thisAlerts:
@slimjimauthorJan 06.2005 — Well i put that in frame1 and it still get no alert if a page with a frame breaker happens.

You mentioned that you put that code on frame2 page.

frame2 in my case isnt a page, but a page that is echoed using the below. I do not have a frame2 page at all.

Here is frame2 where site gets loaded into

[code=php]
<frame name="mainFrame" src="<?php echo $url; ?>">

[/code]
×

Success!

Help @slimjim 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 4.27,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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