Forum Moderators: open

Message Too Old, No Replies

Warning for <a href>

         

tonynoriega

8:35 pm on Sep 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How do you put a javascript warning box that says something similar to: "You are now being taken to another site"

and they must select OK, to continue?

possible using a basic html <a href>?

penders

12:21 am on Sep 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<a href="http://www.example.com" onclick="return confirm('You are now being taken to an external site');">External Site Link</a>

Although it is questionable whether your users would appreciate it! Usually an indication on the link itself that it is an external link is preferable.

cmarshall

1:38 pm on Sep 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't do alerts. You'll become hated.

WikiMedia does something that works well. [meta.wikimedia.org]

Marshall

2:04 pm on Sep 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you have asp capability, there is a really simple asp script for this;

ASP in page its own page, i.e. redirectpage.asp:
<head>
<%
If Request.Querystring("url") <> "" Then
xsite= Request.Querystring("url")
Else
'specify a default page to redirect to
xsite="http://www.yourdomain.com/"
End If
%>
<meta http-equiv="refresh" content="5;Url=<%=xsite%>">
</head>

<body>
<p>You are leaving our web sitep>
<p>If you want to continue visiting our site, <a href="javascript:history.back()">CLICK HERE</a>.</p>
<p>Otherwise you will be redirect to you destination in 5 seconds or you may <a href="<%=xsite%>">CLICK HERE</a> to continue.</p>
<p>Thank you for visiting. Please visit us again soon!</p>
<!-- Below is optional from here -->
<p>You visited us on </p>
<p><%
response.write(FormatDateTime(date(),vblongdate))
response.write(" at ")
response.write(FormatDateTime(now(),vblongtime))
response.write(".")
<!-- to here -->
%>
</p>
</body>

Link in page you are leaving:
<a href="redirectpage.asp?url=http://www.newdestination . com">Link</a>

(Note, I put a space on either side of the period so it would not create an actual link.) This works really well and I would assume there is a php version.

Marshall

rocknbil

9:07 pm on Sep 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I will just add that this is a requirement of some government sites - "you are now being taken to an external site, thisdomain.gov has no control over the content of the site you are about to visit."

In this case, using Javascript will not be possible because the .gov sites also require that functionality is NOT Javascript-dependent (accessibility guidelines,) in which case you need to have the link point to an intermediary server-side script, such as marshall's example. PERL works too! :-)

vincevincevince

1:59 am on Sep 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could just use a dynamic framespage... all links go to
framespage.html?url=http://example.com/

Then, display the top frame at 100px height, fixed, with your logo and some text explaining that the page below is not yours, etc.

The remaining space should be one large frame which contains the URL you sent through.

penders

9:32 pm on Sep 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You could just use a dynamic framespage... all links go to framespage.html?url=http://example.com/

I do the exact same thing on a particular site and it was wokring well until I changed hosts. The same (simple) script works fine on another host also. But on the new host I'm getting the following error returned:

406 Not Acceptable

An appropriate representation of the requested resource /framed.php could not be found on this server.

It doesn't matter what URL I pass. It doesn't matter whether the parameter is urlencode'd. Everthing validates. If I instead hard-code the passed parameter (and not actually pass it) it works fine - the resulting framed page in itself is OK. (?!)

I'm not sure what is going on (I'm guessing some added security on the server?!), but my workaround is to not pass the "http://" part of the URL, but instead append this to the URL in the script, and this works OK!

...just in case anyone has the same issue trying this method!

penders

2:56 pm on Sep 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just a follow up to the "406 Not Acceptable" error I was getting above. I have since found that this was an issue using 'site' as a GET parameter name and the fact that mod_security (Apache) was installed on the server. (Used to prevent certain hacker attempts.)

Rather than pass a relative URL (as mentioned above), simply using a parameter name other than 'site' solves this problem. So using

?url=http://example.com
as in vincevincevince's example should be OK.