...

View Full Version : Open at top problem



jchrisphonte
02-26-2012, 11:52 PM
Hello All,

I have a page that loads in the middle of my page because I added a php search bar that uses jquery and javascript. How can I force the page to open at the top?

Old Pedant
02-27-2012, 01:35 AM
Change your jQuery code? Something in it is moving the focus to the search bar. Find what is doing that and get rid of it.

jchrisphonte
02-27-2012, 03:21 PM
Thank you for the tip Pendant,

sadly Im not familiar with javascript or jquery- I found this code online.... Would you mind pointing out the line to remove if I post the code below?


search_id= '';
function handleHttpResponse() {
if (http.readyState== 4) {
if (search_id != '') {
document.getElementById(search_id).innerHTML= http.responseText;
}
}
}
function getHTTPObject() {
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp= new XMLHttpRequest();
} catch (e) {
xmlhttp= false;
}
}
return xmlhttp;
}
var http= getHTTPObject();

function getScriptPage(div_id,terms_id,get_count,get_p) {
search_id= div_id;
zearch= document.getElementById(terms_id).value;
http.open("GET", "search.php?terms=" + escape(zearch)+"&count="+get_count+"&page="+get_p, true);
http.onreadystatechange= handleHttpResponse;
http.send(null);
}

another page use by search bar:


function GetXmlHttpObject(handler)
{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
// show_results will be filled with new page
document.getElementById("show_results").innerHTML= xmlHttp.responseText;
document.getElementById("show_results").scrollIntoView();
}
}

function htmlData(url, terms, pag)
{
if (url.length==0)
{
document.getElementById("show_results").innerHTML= "";
return;
}

xmlHttp= GetXmlHttpObject();

if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}

url=url+"?"+terms+"&"+pag;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange= stateChanged;
xmlHttp.open("GET",url,true) ;
xmlHttp.send(null);
}

Old Pedant
02-27-2012, 11:17 PM
It's this line:


document.getElementById("show_results").scrollIntoView();


Try commenting it out ( put // in front of the line ) and see if that does it. It should.

I don't see anything in the first block of code that would do this.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum