Preventing Page Reload

S

sawyersam44

Hi All

Programming newbie here, so please be gentle :)

I've noticed some websites have a URL checking script that check to see
the URL in the address bar of the browswer, and can reload/redirect the
page based on this. For example, take the chunk of code below (excuse
the ugly formatting - its a decent size chunk, and I tried to compact
it somewhat)

<script language="JavaScript">
checkURL();
function checkURLl() {
try
{ if (
top.location.hostname!="www.yahoo.com") {
exit=false;
if ( (top.location.hostname).indexOf("yahoo") != -1 )
{ parent.location="http://www.yahoo.com"; }
} }
catch(e)
{
exit=false;
var loc = document.URL;
if ( loc.indexOf("yahoo") != -1 )
{ parent.location="http://www.yahoo.com"; }
} }
function placeFocus() {
checkURL();
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements.type == "text") || (field.elements.type ==
"textarea") || (field.elements.type.toString().charAt(0) == "s")) {
document.forms[0].elements.focus();
break;
} } } }
</script>

This code is (supposed) to make sure that the proper URL is in the
address bar (here it would be yahoo.com), and if not, it would reload
the browser using the proper URL. An example of this would be someone
who is hiding the URL they are sending you to using frames. So even
though you are looking at the yahoo.com website, the URL in your
address bar shows something besides yahoo.com. Is there a way to defeat
this script short of disabling Javascript in the browser?

TIA
Samantha
 
S

shimmyshack

yes, just hit stop before it gets executed. for instance when you use
google translate to translate mail.yahoo.com from english to english to
defeat bossy IT staff who have tried to ban google it will try to
refresh, just hit stop, and login as normal to the yahoo beta. job done

If you are talking about writing script that stops it, then try
greasemonkey extension in firefox, and inject

window.onunload = function()
{
confirm('you really want to navigate away?');
}

that kind of thing.

If the redirect is on a loop or interval though you will be answering
that question alot, however if you just stop it from unloading
completely, yuo will not be able to navigate away when you want to.

what about injecting a checkbox top right, which starts off checked,
then your onunload statement would be

//pseudocode
if(checkbox is checked)
{
window.onunload = function()
{
return false;
}
}
else
{
confirm('leave page?');
}


Or another method, how about using a proxy server like fiddlertool on
windows which you then write a rule for which parses out certain
javascript phrases so that no redirect code is ever present in the
webpages. This would slow up your browsing as all pages would go via
fiddler, so then install the foxyproxy extension and set it up to only
redirect certain known annoying javascripts, and urls to the proxy,
leaving others to pass through.

Ah white-hat hacking, i love it. But just be ethical, use it for good.

;)
 
R

Randy Webb

(e-mail address removed) said the following on 10/27/2006 3:51 PM:

Is there a way to defeat this script short of disabling
Javascript in the browser?

Yes, stop trying to frame someone else's content and you don't have to
worry about it anymore.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top