Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

Stop loading page if external link redirects

I have many external links on my website and sometimes I find that the URL is redirected to adult sites. I want a inline script for the links on my page to check the URL of the link with the URL of the page it is trying to load and if it is not the same then stop loading it.
0
garylake
Asked:
garylake
1 Solution
 
Michel PlungjanIT ExpertCommented:
No way

You need a server process
0
 
lexxwernCommented:
what sort of links are these which redirect wierdly?

if its an outside link you should complain to the people incharge.

client side definitely not possible, server side depends . . . i dont see a cgi checking file parameters on other servers.
0
 
Michel PlungjanIT ExpertCommented:
A cgi can request a head - if it is a 302 or such it can deny the link.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ipisCommented:
I fully agree with the above comments - you could "catch" a redirection BEFORE the page is loaded only on the server, but what to do if you don't have an access to the server's cgi. It is not easy, if possible at all.
Here is a (not so) simple idea that may be could stop showing of "wrong" pages in IE

1. open the pages of your site in frameset with one frame - the frameset could hold js variables to check the location of the document in the frame.

2. secure the "top" window document (the frameset) for beeing changed from the frame - use the event onbeforeunload - here is the example from MSDN :
<head>
<script>
function closeIt()
  {
    event.returnValue = "Any string value here forces a dialog box to appear before closing the window.";
  }
</SCRIPT>
</HEAD>
<BODY onbeforeunload="closeIt()">
    <a href="http://www.microsoft.com">Click here to navigate to
        www.microsoft.com</a>
</BODY>
However there is no way to prevent showing of the page if the user confirms it, but may be you could open new window with your site and close this one within the function (i am not sure if possible)

3. always change the location in the frame through functions in the frameset (top)
-"onunload" save the url of the current page and make the frame invisible (through style),
- get the url to load (with assigning of behavior to the a and form in css)
-load the requested url,
-"onload" check the real url of the loaded document
- if it is the expected make the frame visible, if not load the saved url

I have to say that I never tried this so I expect your comments and critics :)

Ivan


0
 
ahosangCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
ahosang
EE Cleanup Volunteer
0
 
moduloCommented:
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now