Solved

Stop loading page if external link redirects

Posted on 2002-06-26
6
258 Views
Last Modified: 2012-06-21
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
Comment
Question by:garylake
6 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 7110303
No way

You need a server process
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 7110588
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 7110949
A cgi can request a head - if it is a 302 or such it can deny the link.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 

Expert Comment

by:ipis
ID: 7112977
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
 
LVL 12

Expert Comment

by:ahosang
ID: 8286333
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
 

Accepted Solution

by:
modulo earned 0 total points
ID: 8360782
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question