I have a unique question .
Suppose we attach a Javascript to a link.
When we click the link a JS function is called and the body of the web page moves to the top if we had scrolled down the page.
I want to stop the web page from going to the top.
How to do this ?
9 1418
Post your code which does this, so that it can be altered.
One more thing: please do not bump up your thread if you have nothing new to say. Different time zones mean that responses cannot be immediate. If it's been 24 hours, then you might consider doing that, perhaps with a more detailed explanation including code (then I won't mind!)
This is my code --> - <script type="text/javascript" src="/ps/js/prototype.js"></script>
-
<script language="Javascript">
-
function getHTML(num) {
-
if(num == undefined) {
-
var num = document.getElementById('refid').value;
-
}
-
var num = num;
-
var url = '/cgi-bin/ps/srch.cgi';
-
var pars = 'num='+num+'&act=showattachedfilesection';
-
var myAjax = new Ajax.Updater( {success: 'placeholder'}, url, { method: 'get', parameters: pars, onFailure: reportError });
-
}
-
-
function getSrchResults() {
-
document.getElementById('systemWorking').style.visibility = 'visible';
-
var textbox = document.getElementById('data').value;
-
var ex = document.getElementById('exact');
-
if(ex.checked) {
-
var exact = 1;
-
}
-
var a = document.getElementById('and');
-
if(a.checked) {
-
var and = 1;
-
}
-
var se = document.getElementById('sequence');
-
if(se.checked) {
-
var seq = 1;
-
}
-
var url = '/cgi-bin/ps/srch.cgi';
-
var pars = 'data='+textbox+'&exact='+exact+'&and='+and+'&seq='+seq+'&act=search';
-
var myAjax = new Ajax.Updater( {success: 'searchplaceholder'}, url, { method: 'get', parameters: pars,onFailure: reportError });
-
}
-
-
function reportError(request) {
-
alert('Sorry. There was an error.');
-
}
-
-
var myGlobalHandlers = {
-
onCreate: function(){
-
Element.show('systemWorking');
-
},
-
onComplete: function() {
-
if(Ajax.activeRequestCount == 0){
-
Element.hide('systemWorking');
-
}
-
}
-
};
-
-
Ajax.Responders.register(myGlobalHandlers);
-
</script>
-
-
<table cellpadding="0" cellspacing="0" width="73%" align="center">
-
<tr><td class="punchintitle" colspan="9">Search Database</td></tr>
-
<tr>
-
<td class="report" align="right" width="20%">Keywords </td>
-
<td class="report" align="left" width="40%"><input type="textbox" id="data" size="40" maxlength="200"/></td>
-
<td class="report" align="right">Exact</td>
-
<td class="report"><input type="checkbox" id="exact"/></td>
-
<td class="report" align="right">AND</td>
-
<td class="report"><input type="checkbox" id="and"/></td>
-
<td class="report" align="right" width="10%">Sequence</td>
-
<td class="report"><input type="checkbox" id="sequence"/></td>
-
<td class="report" align="right"><a href="#" onClick="getSrchResults();">Search</a></td>
-
<td><div id='systemWorking' align="center" style="visibility:hidden;"><img src='/ps/imgs/animated-circle-ball.gif'></div></td>
-
</tr>
-
</table>
-
-
<br/>
-
<div id="srchplaceholder"></div>
-
-
<br/><br/>
-
<div id="placeholder"></div>
I am using Ajax to replace the "placeholders" present in the DIVs above .
Whenever I click on the Search link the page goes up.
I want the page to be at the current place .
The above code is present in a HTML template which gets values from a Perl CGI file.
Also I don't think there is any need of code because this is a general phenomenon. I got the solution using anchors -->
<a href="#bottomanchor">Go to Bottom</a>
<a name="bottomanchor"></a>
Glad you got your problem solved and thank you for posting and sharing your solution.
<a href="javascript: void(0)" onclick="whatever">
<a href="javascript: void(0)" onclick="whatever">
Yes, looking back at the code, this is a much better solution. Using the anchors will achieve what you want but it's still moving to somewhere.
Change - <a href="#" onClick="getSrchResults();">Search</a>
to - <a href="javascript:void(0)" onClick="getSrchResults();">Search</a>
javascript :void(0) causes a dead link.
ya you all are right .
But I want to move down so I used the anchors.
If I have to remain in that position then I will use your code.
Thanks for the code.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: William Wisnieski |
last post by:
Hello Everyone,
Access 2000
I have a form with multiple pages on it. There is one text field
on the third page of the form that I need the user to
complete before leaving the form or moving...
|
by: John Lau |
last post by:
Hi,
Is there documentation that talks about the page lifecycle, the lifecycle of
controls on the page, and the rendering of inline code, in a single
document?
Thanks,
John
|
by: Geoff C Melbourne |
last post by:
I'm new to asp.net.
I have an ASP.Net form that contains literally 50 fields for the user to
enter for a contacts details.
All these fields are stored in the one table.
So I have a class that...
|
by: pavan377 |
last post by:
Hi folks,
I got a requirement in my project where in when my application is activated another window should get activated and upon it my application should be present. Both should be in restored...
|
by: SammyBar |
last post by:
Hi all,
I'm having troubles with a Symbol 9000 device (Compact Framework v 1.1) when
activating the barcode scanner from a window. The problem is related to the
Activated event of the form which...
|
by: google |
last post by:
I have a form with several subforms. Users enter the data, then on the
parent there is a command button that runs code to generate a .pdf
document from a report based on the data they are working...
|
by: intheshade |
last post by:
hi! I'm trying to implement actionscript so that when the user moves the cursor, the page moves, revealing areas of the page that were previously outside the boundaries. basically, the user moves the...
|
by: ABCL |
last post by:
Hi
I have aspx page that has a html link on it( <a
href="javascript:window.open('xxx.aspx')";..)
When I click this link If should open new window usng javascript, But
it gives me a message...
|
by: koren99 |
last post by:
Hello,
I have a gridview that is filled with a datasource & template fields dynamically.
( that has to be done because i ask the user for a datasource)
anyway, i started out creating a static...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |