vBulletin

Thank you for visiting. This is our website archive. Please visit our main website by clicking the banner above.
vBulletin FAQ is dedicated to helping the forum owner build, manage and profit from his vBulletin Forum
vBulletin Web Hosting - Free skins and styles for your vBulletin - Search Engine Optimization




Forcing #top onto URLs

sarahk
07-19-2005, 11:49 AM
I'm just finishing off a forum which is shown in a wrapper on a mambo site. That means it's shown in an iframe.

I know vB has <a name="top"></a>
<!-- content table -->at the top of all it's pages, and I need that to be used.

Scenario: user registers and gets the "confirmation email has been sent" message but the page is scrolled halfway down and the user can't see it.

Has anyone tackled this - what's the best solution?

thanks

Sarah

minstrel
07-19-2005, 08:38 PM
I'm assuming you load a confirmation page that contains that message. Specify the page to load as follows:

<a href="www.domain.com/confirmation.php" target="_top">

sarahk
07-19-2005, 08:55 PM
Thanks Minstrel

I needed a solution that worked for each and every page as we'd found the problem existed under a number of circumstances and it wasn't appropriate to tackle each.

The _top wasn't going to work because it's #top in the page, not the top of the browser.

So, this is what I have

vB is told to link to an external javascript file. When the file loads it looks to see if the wrapper is enforced - which it won't be if you've clicked on an email notification or done a right click open in new window request.

If that's not the case then lets see if #hash has already been filled. What? can't do that yet? OK, lets add an onload event so that when the page is filled we can do it. And if not, then we go to the top - everytime.

It works in Firefox and IE6, but it may not be perfect. Any feedback would be apprecaited.

//=======================================
// functions
//=======================================
function replaceWindowURL( win, url )
{
win.location.href = url;
}
function getWindowURL( win )
{
return unescape(win.location.href);
}

function addOnLoadEvent(obj, evType, fn)
{
if (obj.addEventListener)
{
obj.addEventListener(evType, fn, false);
return true;
}
else if (obj.attachEvent)
{
obj.attachEvent("on"+evType, fn);
return true;
}
else
{
return false;
}
}

function setToTop()
{
top.location.hash = '#top';
self.location.hash = '#top';
//alert('in setToTop');
}

//=======================================
// active script
//=======================================


var divert = true;
var thisURL = getWindowURL(self);
var test = new String(thisURL);

if ( top == self )
{
var homeURL = "http://www.mysite.com/component/option,com_wrapper/Itemid,74/?url=";

if (test.indexOf('newattachment') > 0) divert = false;
if (test.indexOf('admincp') > 0) divert = false;
if (test.indexOf('register.php') > 0) divert = false;
if (test.indexOf('reputation.php') > 0) divert = false;

if (divert)
{
var url = homeURL + thisURL;

replaceWindowURL( top, url );
}
}
else
{
//check for top of page
if (test.indexOf('#') > 0) divert = false;

if (divert) addOnLoadEvent(self, 'load', setToTop);
}


And the site owners have opened it up so you can see it working... http://www.propertytalk.com


vBulletin

seo book

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum